
kernel/kernel:     file format elf64-littleriscv


Disassembly of section .text:

0000000080000000 <_entry>:
    80000000:	00008117          	auipc	sp,0x8
    80000004:	04013103          	ld	sp,64(sp) # 80008040 <_GLOBAL_OFFSET_TABLE_+0x8>
    80000008:	6505                	lui	a0,0x1
    8000000a:	f14025f3          	csrr	a1,mhartid
    8000000e:	0585                	addi	a1,a1,1
    80000010:	02b50533          	mul	a0,a0,a1
    80000014:	912a                	add	sp,sp,a0
    80000016:	072000ef          	jal	ra,80000088 <start>

000000008000001a <junk>:
    8000001a:	a001                	j	8000001a <junk>

000000008000001c <timerinit>:
// which arrive at timervec in kernelvec.S,
// which turns them into software interrupts for
// devintr() in trap.c.
void
timerinit()
{
    8000001c:	1141                	addi	sp,sp,-16
    8000001e:	e422                	sd	s0,8(sp)
    80000020:	0800                	addi	s0,sp,16
// which hart (core) is this?
static inline uint64
r_mhartid()
{
  uint64 x;
  asm volatile("csrr %0, mhartid" : "=r" (x) );
    80000022:	f14027f3          	csrr	a5,mhartid
  // each CPU has a separate source of timer interrupts.
  int id = r_mhartid();
    80000026:	2781                	sext.w	a5,a5

  // ask the CLINT for a timer interrupt.
  int interval = 1000000; // cycles; about 1/10th second in qemu.
  *(uint64*)CLINT_MTIMECMP(id) = *(uint64*)CLINT_MTIME + interval;
    80000028:	0037969b          	slliw	a3,a5,0x3
    8000002c:	02004737          	lui	a4,0x2004
    80000030:	96ba                	add	a3,a3,a4
    80000032:	0200c737          	lui	a4,0x200c
    80000036:	ff873603          	ld	a2,-8(a4) # 200bff8 <_entry-0x7dff4008>
    8000003a:	000f4737          	lui	a4,0xf4
    8000003e:	24070713          	addi	a4,a4,576 # f4240 <_entry-0x7ff0bdc0>
    80000042:	963a                	add	a2,a2,a4
    80000044:	e290                	sd	a2,0(a3)

  // prepare information in scratch[] for timervec.
  // scratch[0..3] : space for timervec to save registers.
  // scratch[4] : address of CLINT MTIMECMP register.
  // scratch[5] : desired interval (in cycles) between timer interrupts.
  uint64 *scratch = &mscratch0[32 * id];
    80000046:	0057979b          	slliw	a5,a5,0x5
    8000004a:	078e                	slli	a5,a5,0x3
    8000004c:	00009617          	auipc	a2,0x9
    80000050:	fb460613          	addi	a2,a2,-76 # 80009000 <mscratch0>
    80000054:	97b2                	add	a5,a5,a2
  scratch[4] = CLINT_MTIMECMP(id);
    80000056:	f394                	sd	a3,32(a5)
  scratch[5] = interval;
    80000058:	f798                	sd	a4,40(a5)
}

static inline void 
w_mscratch(uint64 x)
{
  asm volatile("csrw mscratch, %0" : : "r" (x));
    8000005a:	34079073          	csrw	mscratch,a5
  asm volatile("csrw mtvec, %0" : : "r" (x));
    8000005e:	00006797          	auipc	a5,0x6
    80000062:	d0278793          	addi	a5,a5,-766 # 80005d60 <timervec>
    80000066:	30579073          	csrw	mtvec,a5
  asm volatile("csrr %0, mstatus" : "=r" (x) );
    8000006a:	300027f3          	csrr	a5,mstatus

  // set the machine-mode trap handler.
  w_mtvec((uint64)timervec);

  // enable machine-mode interrupts.
  w_mstatus(r_mstatus() | MSTATUS_MIE);
    8000006e:	0087e793          	ori	a5,a5,8
  asm volatile("csrw mstatus, %0" : : "r" (x));
    80000072:	30079073          	csrw	mstatus,a5
  asm volatile("csrr %0, mie" : "=r" (x) );
    80000076:	304027f3          	csrr	a5,mie

  // enable machine-mode timer interrupts.
  w_mie(r_mie() | MIE_MTIE);
    8000007a:	0807e793          	ori	a5,a5,128
  asm volatile("csrw mie, %0" : : "r" (x));
    8000007e:	30479073          	csrw	mie,a5
}
    80000082:	6422                	ld	s0,8(sp)
    80000084:	0141                	addi	sp,sp,16
    80000086:	8082                	ret

0000000080000088 <start>:
{
    80000088:	1141                	addi	sp,sp,-16
    8000008a:	e406                	sd	ra,8(sp)
    8000008c:	e022                	sd	s0,0(sp)
    8000008e:	0800                	addi	s0,sp,16
  asm volatile("csrr %0, mstatus" : "=r" (x) );
    80000090:	300027f3          	csrr	a5,mstatus
  x &= ~MSTATUS_MPP_MASK;
    80000094:	7779                	lui	a4,0xffffe
    80000096:	7ff70713          	addi	a4,a4,2047 # ffffffffffffe7ff <ticks+0xffffffff7ffd57d7>
    8000009a:	8ff9                	and	a5,a5,a4
  x |= MSTATUS_MPP_S;
    8000009c:	6705                	lui	a4,0x1
    8000009e:	80070713          	addi	a4,a4,-2048 # 800 <_entry-0x7ffff800>
    800000a2:	8fd9                	or	a5,a5,a4
  asm volatile("csrw mstatus, %0" : : "r" (x));
    800000a4:	30079073          	csrw	mstatus,a5
  asm volatile("csrw mepc, %0" : : "r" (x));
    800000a8:	00001797          	auipc	a5,0x1
    800000ac:	cf278793          	addi	a5,a5,-782 # 80000d9a <main>
    800000b0:	34179073          	csrw	mepc,a5
  asm volatile("csrw satp, %0" : : "r" (x));
    800000b4:	4781                	li	a5,0
    800000b6:	18079073          	csrw	satp,a5
  asm volatile("csrw medeleg, %0" : : "r" (x));
    800000ba:	67c1                	lui	a5,0x10
    800000bc:	17fd                	addi	a5,a5,-1
    800000be:	30279073          	csrw	medeleg,a5
  asm volatile("csrw mideleg, %0" : : "r" (x));
    800000c2:	30379073          	csrw	mideleg,a5
  timerinit();
    800000c6:	00000097          	auipc	ra,0x0
    800000ca:	f56080e7          	jalr	-170(ra) # 8000001c <timerinit>
  asm volatile("csrr %0, mhartid" : "=r" (x) );
    800000ce:	f14027f3          	csrr	a5,mhartid
  w_tp(id);
    800000d2:	2781                	sext.w	a5,a5
}

static inline void 
w_tp(uint64 x)
{
  asm volatile("mv tp, %0" : : "r" (x));
    800000d4:	823e                	mv	tp,a5
  asm volatile("mret");
    800000d6:	30200073          	mret
}
    800000da:	60a2                	ld	ra,8(sp)
    800000dc:	6402                	ld	s0,0(sp)
    800000de:	0141                	addi	sp,sp,16
    800000e0:	8082                	ret

00000000800000e2 <consoleread>:
// user_dist indicates whether dst is a user
// or kernel address.
//
int
consoleread(int user_dst, uint64 dst, int n)
{
    800000e2:	7119                	addi	sp,sp,-128
    800000e4:	fc86                	sd	ra,120(sp)
    800000e6:	f8a2                	sd	s0,112(sp)
    800000e8:	f4a6                	sd	s1,104(sp)
    800000ea:	f0ca                	sd	s2,96(sp)
    800000ec:	ecce                	sd	s3,88(sp)
    800000ee:	e8d2                	sd	s4,80(sp)
    800000f0:	e4d6                	sd	s5,72(sp)
    800000f2:	e0da                	sd	s6,64(sp)
    800000f4:	fc5e                	sd	s7,56(sp)
    800000f6:	f862                	sd	s8,48(sp)
    800000f8:	f466                	sd	s9,40(sp)
    800000fa:	f06a                	sd	s10,32(sp)
    800000fc:	ec6e                	sd	s11,24(sp)
    800000fe:	0100                	addi	s0,sp,128
    80000100:	8caa                	mv	s9,a0
    80000102:	8aae                	mv	s5,a1
    80000104:	8a32                	mv	s4,a2
  uint target;
  int c;
  char cbuf;

  target = n;
    80000106:	00060b1b          	sext.w	s6,a2
  acquire(&cons.lock);
    8000010a:	00011517          	auipc	a0,0x11
    8000010e:	6f650513          	addi	a0,a0,1782 # 80011800 <cons>
    80000112:	00001097          	auipc	ra,0x1
    80000116:	9ee080e7          	jalr	-1554(ra) # 80000b00 <acquire>
  while(n > 0){
    8000011a:	09405663          	blez	s4,800001a6 <consoleread+0xc4>
    // wait until interrupt handler has put some
    // input into cons.buffer.
    while(cons.r == cons.w){
    8000011e:	00011497          	auipc	s1,0x11
    80000122:	6e248493          	addi	s1,s1,1762 # 80011800 <cons>
      if(myproc()->killed){
        release(&cons.lock);
        return -1;
      }
      sleep(&cons.r, &cons.lock);
    80000126:	89a6                	mv	s3,s1
    80000128:	00011917          	auipc	s2,0x11
    8000012c:	77090913          	addi	s2,s2,1904 # 80011898 <cons+0x98>
    }

    c = cons.buf[cons.r++ % INPUT_BUF];

    if(c == C('D')){  // end-of-file
    80000130:	4c11                	li	s8,4
      break;
    }

    // copy the input byte to the user-space buffer.
    cbuf = c;
    if(either_copyout(user_dst, dst, &cbuf, 1) == -1)
    80000132:	5d7d                	li	s10,-1
      break;

    dst++;
    --n;

    if(c == '\n'){
    80000134:	4da9                	li	s11,10
    while(cons.r == cons.w){
    80000136:	0984a783          	lw	a5,152(s1)
    8000013a:	09c4a703          	lw	a4,156(s1)
    8000013e:	02f71463          	bne	a4,a5,80000166 <consoleread+0x84>
      if(myproc()->killed){
    80000142:	00001097          	auipc	ra,0x1
    80000146:	75c080e7          	jalr	1884(ra) # 8000189e <myproc>
    8000014a:	591c                	lw	a5,48(a0)
    8000014c:	eba5                	bnez	a5,800001bc <consoleread+0xda>
      sleep(&cons.r, &cons.lock);
    8000014e:	85ce                	mv	a1,s3
    80000150:	854a                	mv	a0,s2
    80000152:	00002097          	auipc	ra,0x2
    80000156:	f5a080e7          	jalr	-166(ra) # 800020ac <sleep>
    while(cons.r == cons.w){
    8000015a:	0984a783          	lw	a5,152(s1)
    8000015e:	09c4a703          	lw	a4,156(s1)
    80000162:	fef700e3          	beq	a4,a5,80000142 <consoleread+0x60>
    c = cons.buf[cons.r++ % INPUT_BUF];
    80000166:	0017871b          	addiw	a4,a5,1
    8000016a:	08e4ac23          	sw	a4,152(s1)
    8000016e:	07f7f713          	andi	a4,a5,127
    80000172:	9726                	add	a4,a4,s1
    80000174:	01874703          	lbu	a4,24(a4)
    80000178:	00070b9b          	sext.w	s7,a4
    if(c == C('D')){  // end-of-file
    8000017c:	078b8863          	beq	s7,s8,800001ec <consoleread+0x10a>
    cbuf = c;
    80000180:	f8e407a3          	sb	a4,-113(s0)
    if(either_copyout(user_dst, dst, &cbuf, 1) == -1)
    80000184:	4685                	li	a3,1
    80000186:	f8f40613          	addi	a2,s0,-113
    8000018a:	85d6                	mv	a1,s5
    8000018c:	8566                	mv	a0,s9
    8000018e:	00002097          	auipc	ra,0x2
    80000192:	146080e7          	jalr	326(ra) # 800022d4 <either_copyout>
    80000196:	01a50863          	beq	a0,s10,800001a6 <consoleread+0xc4>
    dst++;
    8000019a:	0a85                	addi	s5,s5,1
    --n;
    8000019c:	3a7d                	addiw	s4,s4,-1
    if(c == '\n'){
    8000019e:	01bb8463          	beq	s7,s11,800001a6 <consoleread+0xc4>
  while(n > 0){
    800001a2:	f80a1ae3          	bnez	s4,80000136 <consoleread+0x54>
      // a whole line has arrived, return to
      // the user-level read().
      break;
    }
  }
  release(&cons.lock);
    800001a6:	00011517          	auipc	a0,0x11
    800001aa:	65a50513          	addi	a0,a0,1626 # 80011800 <cons>
    800001ae:	00001097          	auipc	ra,0x1
    800001b2:	9ba080e7          	jalr	-1606(ra) # 80000b68 <release>

  return target - n;
    800001b6:	414b053b          	subw	a0,s6,s4
    800001ba:	a811                	j	800001ce <consoleread+0xec>
        release(&cons.lock);
    800001bc:	00011517          	auipc	a0,0x11
    800001c0:	64450513          	addi	a0,a0,1604 # 80011800 <cons>
    800001c4:	00001097          	auipc	ra,0x1
    800001c8:	9a4080e7          	jalr	-1628(ra) # 80000b68 <release>
        return -1;
    800001cc:	557d                	li	a0,-1
}
    800001ce:	70e6                	ld	ra,120(sp)
    800001d0:	7446                	ld	s0,112(sp)
    800001d2:	74a6                	ld	s1,104(sp)
    800001d4:	7906                	ld	s2,96(sp)
    800001d6:	69e6                	ld	s3,88(sp)
    800001d8:	6a46                	ld	s4,80(sp)
    800001da:	6aa6                	ld	s5,72(sp)
    800001dc:	6b06                	ld	s6,64(sp)
    800001de:	7be2                	ld	s7,56(sp)
    800001e0:	7c42                	ld	s8,48(sp)
    800001e2:	7ca2                	ld	s9,40(sp)
    800001e4:	7d02                	ld	s10,32(sp)
    800001e6:	6de2                	ld	s11,24(sp)
    800001e8:	6109                	addi	sp,sp,128
    800001ea:	8082                	ret
      if(n < target){
    800001ec:	000a071b          	sext.w	a4,s4
    800001f0:	fb677be3          	bleu	s6,a4,800001a6 <consoleread+0xc4>
        cons.r--;
    800001f4:	00011717          	auipc	a4,0x11
    800001f8:	6af72223          	sw	a5,1700(a4) # 80011898 <cons+0x98>
    800001fc:	b76d                	j	800001a6 <consoleread+0xc4>

00000000800001fe <consputc>:
  if(panicked){
    800001fe:	00029797          	auipc	a5,0x29
    80000202:	e0278793          	addi	a5,a5,-510 # 80029000 <end>
    80000206:	439c                	lw	a5,0(a5)
    80000208:	2781                	sext.w	a5,a5
    8000020a:	c391                	beqz	a5,8000020e <consputc+0x10>
    for(;;)
    8000020c:	a001                	j	8000020c <consputc+0xe>
{
    8000020e:	1141                	addi	sp,sp,-16
    80000210:	e406                	sd	ra,8(sp)
    80000212:	e022                	sd	s0,0(sp)
    80000214:	0800                	addi	s0,sp,16
  if(c == BACKSPACE){
    80000216:	10000793          	li	a5,256
    8000021a:	00f50a63          	beq	a0,a5,8000022e <consputc+0x30>
    uartputc(c);
    8000021e:	00000097          	auipc	ra,0x0
    80000222:	5f8080e7          	jalr	1528(ra) # 80000816 <uartputc>
}
    80000226:	60a2                	ld	ra,8(sp)
    80000228:	6402                	ld	s0,0(sp)
    8000022a:	0141                	addi	sp,sp,16
    8000022c:	8082                	ret
    uartputc('\b'); uartputc(' '); uartputc('\b');
    8000022e:	4521                	li	a0,8
    80000230:	00000097          	auipc	ra,0x0
    80000234:	5e6080e7          	jalr	1510(ra) # 80000816 <uartputc>
    80000238:	02000513          	li	a0,32
    8000023c:	00000097          	auipc	ra,0x0
    80000240:	5da080e7          	jalr	1498(ra) # 80000816 <uartputc>
    80000244:	4521                	li	a0,8
    80000246:	00000097          	auipc	ra,0x0
    8000024a:	5d0080e7          	jalr	1488(ra) # 80000816 <uartputc>
    8000024e:	bfe1                	j	80000226 <consputc+0x28>

0000000080000250 <consolewrite>:
{
    80000250:	715d                	addi	sp,sp,-80
    80000252:	e486                	sd	ra,72(sp)
    80000254:	e0a2                	sd	s0,64(sp)
    80000256:	fc26                	sd	s1,56(sp)
    80000258:	f84a                	sd	s2,48(sp)
    8000025a:	f44e                	sd	s3,40(sp)
    8000025c:	f052                	sd	s4,32(sp)
    8000025e:	ec56                	sd	s5,24(sp)
    80000260:	0880                	addi	s0,sp,80
    80000262:	89aa                	mv	s3,a0
    80000264:	84ae                	mv	s1,a1
    80000266:	8ab2                	mv	s5,a2
  acquire(&cons.lock);
    80000268:	00011517          	auipc	a0,0x11
    8000026c:	59850513          	addi	a0,a0,1432 # 80011800 <cons>
    80000270:	00001097          	auipc	ra,0x1
    80000274:	890080e7          	jalr	-1904(ra) # 80000b00 <acquire>
  for(i = 0; i < n; i++){
    80000278:	03505e63          	blez	s5,800002b4 <consolewrite+0x64>
    8000027c:	00148913          	addi	s2,s1,1
    80000280:	fffa879b          	addiw	a5,s5,-1
    80000284:	1782                	slli	a5,a5,0x20
    80000286:	9381                	srli	a5,a5,0x20
    80000288:	993e                	add	s2,s2,a5
    if(either_copyin(&c, user_src, src+i, 1) == -1)
    8000028a:	5a7d                	li	s4,-1
    8000028c:	4685                	li	a3,1
    8000028e:	8626                	mv	a2,s1
    80000290:	85ce                	mv	a1,s3
    80000292:	fbf40513          	addi	a0,s0,-65
    80000296:	00002097          	auipc	ra,0x2
    8000029a:	094080e7          	jalr	148(ra) # 8000232a <either_copyin>
    8000029e:	01450b63          	beq	a0,s4,800002b4 <consolewrite+0x64>
    consputc(c);
    800002a2:	fbf44503          	lbu	a0,-65(s0)
    800002a6:	00000097          	auipc	ra,0x0
    800002aa:	f58080e7          	jalr	-168(ra) # 800001fe <consputc>
  for(i = 0; i < n; i++){
    800002ae:	0485                	addi	s1,s1,1
    800002b0:	fd249ee3          	bne	s1,s2,8000028c <consolewrite+0x3c>
  release(&cons.lock);
    800002b4:	00011517          	auipc	a0,0x11
    800002b8:	54c50513          	addi	a0,a0,1356 # 80011800 <cons>
    800002bc:	00001097          	auipc	ra,0x1
    800002c0:	8ac080e7          	jalr	-1876(ra) # 80000b68 <release>
}
    800002c4:	8556                	mv	a0,s5
    800002c6:	60a6                	ld	ra,72(sp)
    800002c8:	6406                	ld	s0,64(sp)
    800002ca:	74e2                	ld	s1,56(sp)
    800002cc:	7942                	ld	s2,48(sp)
    800002ce:	79a2                	ld	s3,40(sp)
    800002d0:	7a02                	ld	s4,32(sp)
    800002d2:	6ae2                	ld	s5,24(sp)
    800002d4:	6161                	addi	sp,sp,80
    800002d6:	8082                	ret

00000000800002d8 <consoleintr>:
// do erase/kill processing, append to cons.buf,
// wake up consoleread() if a whole line has arrived.
//
void
consoleintr(int c)
{
    800002d8:	1101                	addi	sp,sp,-32
    800002da:	ec06                	sd	ra,24(sp)
    800002dc:	e822                	sd	s0,16(sp)
    800002de:	e426                	sd	s1,8(sp)
    800002e0:	e04a                	sd	s2,0(sp)
    800002e2:	1000                	addi	s0,sp,32
    800002e4:	84aa                	mv	s1,a0
  acquire(&cons.lock);
    800002e6:	00011517          	auipc	a0,0x11
    800002ea:	51a50513          	addi	a0,a0,1306 # 80011800 <cons>
    800002ee:	00001097          	auipc	ra,0x1
    800002f2:	812080e7          	jalr	-2030(ra) # 80000b00 <acquire>

  switch(c){
    800002f6:	47c1                	li	a5,16
    800002f8:	12f48463          	beq	s1,a5,80000420 <consoleintr+0x148>
    800002fc:	0297df63          	ble	s1,a5,8000033a <consoleintr+0x62>
    80000300:	47d5                	li	a5,21
    80000302:	0af48863          	beq	s1,a5,800003b2 <consoleintr+0xda>
    80000306:	07f00793          	li	a5,127
    8000030a:	02f49b63          	bne	s1,a5,80000340 <consoleintr+0x68>
      consputc(BACKSPACE);
    }
    break;
  case C('H'): // Backspace
  case '\x7f':
    if(cons.e != cons.w){
    8000030e:	00011717          	auipc	a4,0x11
    80000312:	4f270713          	addi	a4,a4,1266 # 80011800 <cons>
    80000316:	0a072783          	lw	a5,160(a4)
    8000031a:	09c72703          	lw	a4,156(a4)
    8000031e:	10f70563          	beq	a4,a5,80000428 <consoleintr+0x150>
      cons.e--;
    80000322:	37fd                	addiw	a5,a5,-1
    80000324:	00011717          	auipc	a4,0x11
    80000328:	56f72e23          	sw	a5,1404(a4) # 800118a0 <cons+0xa0>
      consputc(BACKSPACE);
    8000032c:	10000513          	li	a0,256
    80000330:	00000097          	auipc	ra,0x0
    80000334:	ece080e7          	jalr	-306(ra) # 800001fe <consputc>
    80000338:	a8c5                	j	80000428 <consoleintr+0x150>
  switch(c){
    8000033a:	47a1                	li	a5,8
    8000033c:	fcf489e3          	beq	s1,a5,8000030e <consoleintr+0x36>
    }
    break;
  default:
    if(c != 0 && cons.e-cons.r < INPUT_BUF){
    80000340:	c4e5                	beqz	s1,80000428 <consoleintr+0x150>
    80000342:	00011717          	auipc	a4,0x11
    80000346:	4be70713          	addi	a4,a4,1214 # 80011800 <cons>
    8000034a:	0a072783          	lw	a5,160(a4)
    8000034e:	09872703          	lw	a4,152(a4)
    80000352:	9f99                	subw	a5,a5,a4
    80000354:	07f00713          	li	a4,127
    80000358:	0cf76863          	bltu	a4,a5,80000428 <consoleintr+0x150>
      c = (c == '\r') ? '\n' : c;
    8000035c:	47b5                	li	a5,13
    8000035e:	0ef48363          	beq	s1,a5,80000444 <consoleintr+0x16c>

      // echo back to the user.
      consputc(c);
    80000362:	8526                	mv	a0,s1
    80000364:	00000097          	auipc	ra,0x0
    80000368:	e9a080e7          	jalr	-358(ra) # 800001fe <consputc>

      // store for consumption by consoleread().
      cons.buf[cons.e++ % INPUT_BUF] = c;
    8000036c:	00011797          	auipc	a5,0x11
    80000370:	49478793          	addi	a5,a5,1172 # 80011800 <cons>
    80000374:	0a07a703          	lw	a4,160(a5)
    80000378:	0017069b          	addiw	a3,a4,1
    8000037c:	0006861b          	sext.w	a2,a3
    80000380:	0ad7a023          	sw	a3,160(a5)
    80000384:	07f77713          	andi	a4,a4,127
    80000388:	97ba                	add	a5,a5,a4
    8000038a:	00978c23          	sb	s1,24(a5)

      if(c == '\n' || c == C('D') || cons.e == cons.r+INPUT_BUF){
    8000038e:	47a9                	li	a5,10
    80000390:	0ef48163          	beq	s1,a5,80000472 <consoleintr+0x19a>
    80000394:	4791                	li	a5,4
    80000396:	0cf48e63          	beq	s1,a5,80000472 <consoleintr+0x19a>
    8000039a:	00011797          	auipc	a5,0x11
    8000039e:	46678793          	addi	a5,a5,1126 # 80011800 <cons>
    800003a2:	0987a783          	lw	a5,152(a5)
    800003a6:	0807879b          	addiw	a5,a5,128
    800003aa:	06f61f63          	bne	a2,a5,80000428 <consoleintr+0x150>
      cons.buf[cons.e++ % INPUT_BUF] = c;
    800003ae:	863e                	mv	a2,a5
    800003b0:	a0c9                	j	80000472 <consoleintr+0x19a>
    while(cons.e != cons.w &&
    800003b2:	00011717          	auipc	a4,0x11
    800003b6:	44e70713          	addi	a4,a4,1102 # 80011800 <cons>
    800003ba:	0a072783          	lw	a5,160(a4)
    800003be:	09c72703          	lw	a4,156(a4)
    800003c2:	06f70363          	beq	a4,a5,80000428 <consoleintr+0x150>
          cons.buf[(cons.e-1) % INPUT_BUF] != '\n'){
    800003c6:	37fd                	addiw	a5,a5,-1
    800003c8:	0007871b          	sext.w	a4,a5
    800003cc:	07f7f793          	andi	a5,a5,127
    800003d0:	00011697          	auipc	a3,0x11
    800003d4:	43068693          	addi	a3,a3,1072 # 80011800 <cons>
    800003d8:	97b6                	add	a5,a5,a3
    while(cons.e != cons.w &&
    800003da:	0187c683          	lbu	a3,24(a5)
    800003de:	47a9                	li	a5,10
      cons.e--;
    800003e0:	00011497          	auipc	s1,0x11
    800003e4:	42048493          	addi	s1,s1,1056 # 80011800 <cons>
    while(cons.e != cons.w &&
    800003e8:	4929                	li	s2,10
    800003ea:	02f68f63          	beq	a3,a5,80000428 <consoleintr+0x150>
      cons.e--;
    800003ee:	0ae4a023          	sw	a4,160(s1)
      consputc(BACKSPACE);
    800003f2:	10000513          	li	a0,256
    800003f6:	00000097          	auipc	ra,0x0
    800003fa:	e08080e7          	jalr	-504(ra) # 800001fe <consputc>
    while(cons.e != cons.w &&
    800003fe:	0a04a783          	lw	a5,160(s1)
    80000402:	09c4a703          	lw	a4,156(s1)
    80000406:	02f70163          	beq	a4,a5,80000428 <consoleintr+0x150>
          cons.buf[(cons.e-1) % INPUT_BUF] != '\n'){
    8000040a:	37fd                	addiw	a5,a5,-1
    8000040c:	0007871b          	sext.w	a4,a5
    80000410:	07f7f793          	andi	a5,a5,127
    80000414:	97a6                	add	a5,a5,s1
    while(cons.e != cons.w &&
    80000416:	0187c783          	lbu	a5,24(a5)
    8000041a:	fd279ae3          	bne	a5,s2,800003ee <consoleintr+0x116>
    8000041e:	a029                	j	80000428 <consoleintr+0x150>
    procdump();
    80000420:	00002097          	auipc	ra,0x2
    80000424:	f60080e7          	jalr	-160(ra) # 80002380 <procdump>
      }
    }
    break;
  }
  
  release(&cons.lock);
    80000428:	00011517          	auipc	a0,0x11
    8000042c:	3d850513          	addi	a0,a0,984 # 80011800 <cons>
    80000430:	00000097          	auipc	ra,0x0
    80000434:	738080e7          	jalr	1848(ra) # 80000b68 <release>
}
    80000438:	60e2                	ld	ra,24(sp)
    8000043a:	6442                	ld	s0,16(sp)
    8000043c:	64a2                	ld	s1,8(sp)
    8000043e:	6902                	ld	s2,0(sp)
    80000440:	6105                	addi	sp,sp,32
    80000442:	8082                	ret
      consputc(c);
    80000444:	4529                	li	a0,10
    80000446:	00000097          	auipc	ra,0x0
    8000044a:	db8080e7          	jalr	-584(ra) # 800001fe <consputc>
      cons.buf[cons.e++ % INPUT_BUF] = c;
    8000044e:	00011797          	auipc	a5,0x11
    80000452:	3b278793          	addi	a5,a5,946 # 80011800 <cons>
    80000456:	0a07a703          	lw	a4,160(a5)
    8000045a:	0017069b          	addiw	a3,a4,1
    8000045e:	0006861b          	sext.w	a2,a3
    80000462:	0ad7a023          	sw	a3,160(a5)
    80000466:	07f77713          	andi	a4,a4,127
    8000046a:	97ba                	add	a5,a5,a4
    8000046c:	4729                	li	a4,10
    8000046e:	00e78c23          	sb	a4,24(a5)
        cons.w = cons.e;
    80000472:	00011797          	auipc	a5,0x11
    80000476:	42c7a523          	sw	a2,1066(a5) # 8001189c <cons+0x9c>
        wakeup(&cons.r);
    8000047a:	00011517          	auipc	a0,0x11
    8000047e:	41e50513          	addi	a0,a0,1054 # 80011898 <cons+0x98>
    80000482:	00002097          	auipc	ra,0x2
    80000486:	d76080e7          	jalr	-650(ra) # 800021f8 <wakeup>
    8000048a:	bf79                	j	80000428 <consoleintr+0x150>

000000008000048c <consoleinit>:

void
consoleinit(void)
{
    8000048c:	1141                	addi	sp,sp,-16
    8000048e:	e406                	sd	ra,8(sp)
    80000490:	e022                	sd	s0,0(sp)
    80000492:	0800                	addi	s0,sp,16
  initlock(&cons.lock, "cons");
    80000494:	00007597          	auipc	a1,0x7
    80000498:	c8458593          	addi	a1,a1,-892 # 80007118 <userret+0x88>
    8000049c:	00011517          	auipc	a0,0x11
    800004a0:	36450513          	addi	a0,a0,868 # 80011800 <cons>
    800004a4:	00000097          	auipc	ra,0x0
    800004a8:	54e080e7          	jalr	1358(ra) # 800009f2 <initlock>

  uartinit();
    800004ac:	00000097          	auipc	ra,0x0
    800004b0:	334080e7          	jalr	820(ra) # 800007e0 <uartinit>

  // connect read and write system calls
  // to consoleread and consolewrite.
  devsw[CONSOLE].read = consoleread;
    800004b4:	00021797          	auipc	a5,0x21
    800004b8:	43478793          	addi	a5,a5,1076 # 800218e8 <devsw>
    800004bc:	00000717          	auipc	a4,0x0
    800004c0:	c2670713          	addi	a4,a4,-986 # 800000e2 <consoleread>
    800004c4:	eb98                	sd	a4,16(a5)
  devsw[CONSOLE].write = consolewrite;
    800004c6:	00000717          	auipc	a4,0x0
    800004ca:	d8a70713          	addi	a4,a4,-630 # 80000250 <consolewrite>
    800004ce:	ef98                	sd	a4,24(a5)
}
    800004d0:	60a2                	ld	ra,8(sp)
    800004d2:	6402                	ld	s0,0(sp)
    800004d4:	0141                	addi	sp,sp,16
    800004d6:	8082                	ret

00000000800004d8 <printint>:

static char digits[] = "0123456789abcdef";

static void
printint(int xx, int base, int sign)
{
    800004d8:	7179                	addi	sp,sp,-48
    800004da:	f406                	sd	ra,40(sp)
    800004dc:	f022                	sd	s0,32(sp)
    800004de:	ec26                	sd	s1,24(sp)
    800004e0:	e84a                	sd	s2,16(sp)
    800004e2:	1800                	addi	s0,sp,48
  char buf[16];
  int i;
  uint x;

  if(sign && (sign = xx < 0))
    800004e4:	c219                	beqz	a2,800004ea <printint+0x12>
    800004e6:	00054d63          	bltz	a0,80000500 <printint+0x28>
    x = -xx;
  else
    x = xx;
    800004ea:	2501                	sext.w	a0,a0
    800004ec:	4881                	li	a7,0
    800004ee:	fd040713          	addi	a4,s0,-48

  i = 0;
    800004f2:	4601                	li	a2,0
  do {
    buf[i++] = digits[x % base];
    800004f4:	2581                	sext.w	a1,a1
    800004f6:	00007817          	auipc	a6,0x7
    800004fa:	3da80813          	addi	a6,a6,986 # 800078d0 <digits>
    800004fe:	a801                	j	8000050e <printint+0x36>
    x = -xx;
    80000500:	40a0053b          	negw	a0,a0
    80000504:	2501                	sext.w	a0,a0
  if(sign && (sign = xx < 0))
    80000506:	4885                	li	a7,1
    x = -xx;
    80000508:	b7dd                	j	800004ee <printint+0x16>
  } while((x /= base) != 0);
    8000050a:	853e                	mv	a0,a5
    buf[i++] = digits[x % base];
    8000050c:	8636                	mv	a2,a3
    8000050e:	0016069b          	addiw	a3,a2,1
    80000512:	02b577bb          	remuw	a5,a0,a1
    80000516:	1782                	slli	a5,a5,0x20
    80000518:	9381                	srli	a5,a5,0x20
    8000051a:	97c2                	add	a5,a5,a6
    8000051c:	0007c783          	lbu	a5,0(a5)
    80000520:	00f70023          	sb	a5,0(a4)
  } while((x /= base) != 0);
    80000524:	0705                	addi	a4,a4,1
    80000526:	02b557bb          	divuw	a5,a0,a1
    8000052a:	feb570e3          	bleu	a1,a0,8000050a <printint+0x32>

  if(sign)
    8000052e:	00088b63          	beqz	a7,80000544 <printint+0x6c>
    buf[i++] = '-';
    80000532:	fe040793          	addi	a5,s0,-32
    80000536:	96be                	add	a3,a3,a5
    80000538:	02d00793          	li	a5,45
    8000053c:	fef68823          	sb	a5,-16(a3)
    80000540:	0026069b          	addiw	a3,a2,2

  while(--i >= 0)
    80000544:	02d05763          	blez	a3,80000572 <printint+0x9a>
    80000548:	fd040793          	addi	a5,s0,-48
    8000054c:	00d784b3          	add	s1,a5,a3
    80000550:	fff78913          	addi	s2,a5,-1
    80000554:	9936                	add	s2,s2,a3
    80000556:	36fd                	addiw	a3,a3,-1
    80000558:	1682                	slli	a3,a3,0x20
    8000055a:	9281                	srli	a3,a3,0x20
    8000055c:	40d90933          	sub	s2,s2,a3
    consputc(buf[i]);
    80000560:	fff4c503          	lbu	a0,-1(s1)
    80000564:	00000097          	auipc	ra,0x0
    80000568:	c9a080e7          	jalr	-870(ra) # 800001fe <consputc>
  while(--i >= 0)
    8000056c:	14fd                	addi	s1,s1,-1
    8000056e:	ff2499e3          	bne	s1,s2,80000560 <printint+0x88>
}
    80000572:	70a2                	ld	ra,40(sp)
    80000574:	7402                	ld	s0,32(sp)
    80000576:	64e2                	ld	s1,24(sp)
    80000578:	6942                	ld	s2,16(sp)
    8000057a:	6145                	addi	sp,sp,48
    8000057c:	8082                	ret

000000008000057e <panic>:
    release(&pr.lock);
}

void
panic(char *s)
{
    8000057e:	1101                	addi	sp,sp,-32
    80000580:	ec06                	sd	ra,24(sp)
    80000582:	e822                	sd	s0,16(sp)
    80000584:	e426                	sd	s1,8(sp)
    80000586:	1000                	addi	s0,sp,32
    80000588:	84aa                	mv	s1,a0
  pr.locking = 0;
    8000058a:	00011797          	auipc	a5,0x11
    8000058e:	3207ab23          	sw	zero,822(a5) # 800118c0 <pr+0x18>
  printf("panic: ");
    80000592:	00007517          	auipc	a0,0x7
    80000596:	b8e50513          	addi	a0,a0,-1138 # 80007120 <userret+0x90>
    8000059a:	00000097          	auipc	ra,0x0
    8000059e:	02e080e7          	jalr	46(ra) # 800005c8 <printf>
  printf(s);
    800005a2:	8526                	mv	a0,s1
    800005a4:	00000097          	auipc	ra,0x0
    800005a8:	024080e7          	jalr	36(ra) # 800005c8 <printf>
  printf("\n");
    800005ac:	00007517          	auipc	a0,0x7
    800005b0:	c0450513          	addi	a0,a0,-1020 # 800071b0 <userret+0x120>
    800005b4:	00000097          	auipc	ra,0x0
    800005b8:	014080e7          	jalr	20(ra) # 800005c8 <printf>
  panicked = 1; // freeze other CPUs
    800005bc:	4785                	li	a5,1
    800005be:	00029717          	auipc	a4,0x29
    800005c2:	a4f72123          	sw	a5,-1470(a4) # 80029000 <end>
  for(;;)
    800005c6:	a001                	j	800005c6 <panic+0x48>

00000000800005c8 <printf>:
{
    800005c8:	7131                	addi	sp,sp,-192
    800005ca:	fc86                	sd	ra,120(sp)
    800005cc:	f8a2                	sd	s0,112(sp)
    800005ce:	f4a6                	sd	s1,104(sp)
    800005d0:	f0ca                	sd	s2,96(sp)
    800005d2:	ecce                	sd	s3,88(sp)
    800005d4:	e8d2                	sd	s4,80(sp)
    800005d6:	e4d6                	sd	s5,72(sp)
    800005d8:	e0da                	sd	s6,64(sp)
    800005da:	fc5e                	sd	s7,56(sp)
    800005dc:	f862                	sd	s8,48(sp)
    800005de:	f466                	sd	s9,40(sp)
    800005e0:	f06a                	sd	s10,32(sp)
    800005e2:	ec6e                	sd	s11,24(sp)
    800005e4:	0100                	addi	s0,sp,128
    800005e6:	8aaa                	mv	s5,a0
    800005e8:	e40c                	sd	a1,8(s0)
    800005ea:	e810                	sd	a2,16(s0)
    800005ec:	ec14                	sd	a3,24(s0)
    800005ee:	f018                	sd	a4,32(s0)
    800005f0:	f41c                	sd	a5,40(s0)
    800005f2:	03043823          	sd	a6,48(s0)
    800005f6:	03143c23          	sd	a7,56(s0)
  locking = pr.locking;
    800005fa:	00011797          	auipc	a5,0x11
    800005fe:	2ae78793          	addi	a5,a5,686 # 800118a8 <pr>
    80000602:	0187ad83          	lw	s11,24(a5)
  if(locking)
    80000606:	020d9b63          	bnez	s11,8000063c <printf+0x74>
  if (fmt == 0)
    8000060a:	020a8f63          	beqz	s5,80000648 <printf+0x80>
  va_start(ap, fmt);
    8000060e:	00840793          	addi	a5,s0,8
    80000612:	f8f43423          	sd	a5,-120(s0)
  for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
    80000616:	000ac503          	lbu	a0,0(s5)
    8000061a:	16050063          	beqz	a0,8000077a <printf+0x1b2>
    8000061e:	4481                	li	s1,0
    if(c != '%'){
    80000620:	02500a13          	li	s4,37
    switch(c){
    80000624:	07000b13          	li	s6,112
  consputc('x');
    80000628:	4d41                	li	s10,16
    consputc(digits[x >> (sizeof(uint64) * 8 - 4)]);
    8000062a:	00007b97          	auipc	s7,0x7
    8000062e:	2a6b8b93          	addi	s7,s7,678 # 800078d0 <digits>
    switch(c){
    80000632:	07300c93          	li	s9,115
    80000636:	06400c13          	li	s8,100
    8000063a:	a815                	j	8000066e <printf+0xa6>
    acquire(&pr.lock);
    8000063c:	853e                	mv	a0,a5
    8000063e:	00000097          	auipc	ra,0x0
    80000642:	4c2080e7          	jalr	1218(ra) # 80000b00 <acquire>
    80000646:	b7d1                	j	8000060a <printf+0x42>
    panic("null fmt");
    80000648:	00007517          	auipc	a0,0x7
    8000064c:	ae850513          	addi	a0,a0,-1304 # 80007130 <userret+0xa0>
    80000650:	00000097          	auipc	ra,0x0
    80000654:	f2e080e7          	jalr	-210(ra) # 8000057e <panic>
      consputc(c);
    80000658:	00000097          	auipc	ra,0x0
    8000065c:	ba6080e7          	jalr	-1114(ra) # 800001fe <consputc>
  for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
    80000660:	2485                	addiw	s1,s1,1
    80000662:	009a87b3          	add	a5,s5,s1
    80000666:	0007c503          	lbu	a0,0(a5)
    8000066a:	10050863          	beqz	a0,8000077a <printf+0x1b2>
    if(c != '%'){
    8000066e:	ff4515e3          	bne	a0,s4,80000658 <printf+0x90>
    c = fmt[++i] & 0xff;
    80000672:	2485                	addiw	s1,s1,1
    80000674:	009a87b3          	add	a5,s5,s1
    80000678:	0007c783          	lbu	a5,0(a5)
    8000067c:	0007891b          	sext.w	s2,a5
    if(c == 0)
    80000680:	0e090d63          	beqz	s2,8000077a <printf+0x1b2>
    switch(c){
    80000684:	05678a63          	beq	a5,s6,800006d8 <printf+0x110>
    80000688:	02fb7663          	bleu	a5,s6,800006b4 <printf+0xec>
    8000068c:	09978963          	beq	a5,s9,8000071e <printf+0x156>
    80000690:	07800713          	li	a4,120
    80000694:	0ce79863          	bne	a5,a4,80000764 <printf+0x19c>
      printint(va_arg(ap, int), 16, 1);
    80000698:	f8843783          	ld	a5,-120(s0)
    8000069c:	00878713          	addi	a4,a5,8
    800006a0:	f8e43423          	sd	a4,-120(s0)
    800006a4:	4605                	li	a2,1
    800006a6:	85ea                	mv	a1,s10
    800006a8:	4388                	lw	a0,0(a5)
    800006aa:	00000097          	auipc	ra,0x0
    800006ae:	e2e080e7          	jalr	-466(ra) # 800004d8 <printint>
      break;
    800006b2:	b77d                	j	80000660 <printf+0x98>
    switch(c){
    800006b4:	0b478263          	beq	a5,s4,80000758 <printf+0x190>
    800006b8:	0b879663          	bne	a5,s8,80000764 <printf+0x19c>
      printint(va_arg(ap, int), 10, 1);
    800006bc:	f8843783          	ld	a5,-120(s0)
    800006c0:	00878713          	addi	a4,a5,8
    800006c4:	f8e43423          	sd	a4,-120(s0)
    800006c8:	4605                	li	a2,1
    800006ca:	45a9                	li	a1,10
    800006cc:	4388                	lw	a0,0(a5)
    800006ce:	00000097          	auipc	ra,0x0
    800006d2:	e0a080e7          	jalr	-502(ra) # 800004d8 <printint>
      break;
    800006d6:	b769                	j	80000660 <printf+0x98>
      printptr(va_arg(ap, uint64));
    800006d8:	f8843783          	ld	a5,-120(s0)
    800006dc:	00878713          	addi	a4,a5,8
    800006e0:	f8e43423          	sd	a4,-120(s0)
    800006e4:	0007b983          	ld	s3,0(a5)
  consputc('0');
    800006e8:	03000513          	li	a0,48
    800006ec:	00000097          	auipc	ra,0x0
    800006f0:	b12080e7          	jalr	-1262(ra) # 800001fe <consputc>
  consputc('x');
    800006f4:	07800513          	li	a0,120
    800006f8:	00000097          	auipc	ra,0x0
    800006fc:	b06080e7          	jalr	-1274(ra) # 800001fe <consputc>
    80000700:	896a                	mv	s2,s10
    consputc(digits[x >> (sizeof(uint64) * 8 - 4)]);
    80000702:	03c9d793          	srli	a5,s3,0x3c
    80000706:	97de                	add	a5,a5,s7
    80000708:	0007c503          	lbu	a0,0(a5)
    8000070c:	00000097          	auipc	ra,0x0
    80000710:	af2080e7          	jalr	-1294(ra) # 800001fe <consputc>
  for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
    80000714:	0992                	slli	s3,s3,0x4
    80000716:	397d                	addiw	s2,s2,-1
    80000718:	fe0915e3          	bnez	s2,80000702 <printf+0x13a>
    8000071c:	b791                	j	80000660 <printf+0x98>
      if((s = va_arg(ap, char*)) == 0)
    8000071e:	f8843783          	ld	a5,-120(s0)
    80000722:	00878713          	addi	a4,a5,8
    80000726:	f8e43423          	sd	a4,-120(s0)
    8000072a:	0007b903          	ld	s2,0(a5)
    8000072e:	00090e63          	beqz	s2,8000074a <printf+0x182>
      for(; *s; s++)
    80000732:	00094503          	lbu	a0,0(s2)
    80000736:	d50d                	beqz	a0,80000660 <printf+0x98>
        consputc(*s);
    80000738:	00000097          	auipc	ra,0x0
    8000073c:	ac6080e7          	jalr	-1338(ra) # 800001fe <consputc>
      for(; *s; s++)
    80000740:	0905                	addi	s2,s2,1
    80000742:	00094503          	lbu	a0,0(s2)
    80000746:	f96d                	bnez	a0,80000738 <printf+0x170>
    80000748:	bf21                	j	80000660 <printf+0x98>
        s = "(null)";
    8000074a:	00007917          	auipc	s2,0x7
    8000074e:	9de90913          	addi	s2,s2,-1570 # 80007128 <userret+0x98>
      for(; *s; s++)
    80000752:	02800513          	li	a0,40
    80000756:	b7cd                	j	80000738 <printf+0x170>
      consputc('%');
    80000758:	8552                	mv	a0,s4
    8000075a:	00000097          	auipc	ra,0x0
    8000075e:	aa4080e7          	jalr	-1372(ra) # 800001fe <consputc>
      break;
    80000762:	bdfd                	j	80000660 <printf+0x98>
      consputc('%');
    80000764:	8552                	mv	a0,s4
    80000766:	00000097          	auipc	ra,0x0
    8000076a:	a98080e7          	jalr	-1384(ra) # 800001fe <consputc>
      consputc(c);
    8000076e:	854a                	mv	a0,s2
    80000770:	00000097          	auipc	ra,0x0
    80000774:	a8e080e7          	jalr	-1394(ra) # 800001fe <consputc>
      break;
    80000778:	b5e5                	j	80000660 <printf+0x98>
  if(locking)
    8000077a:	020d9163          	bnez	s11,8000079c <printf+0x1d4>
}
    8000077e:	70e6                	ld	ra,120(sp)
    80000780:	7446                	ld	s0,112(sp)
    80000782:	74a6                	ld	s1,104(sp)
    80000784:	7906                	ld	s2,96(sp)
    80000786:	69e6                	ld	s3,88(sp)
    80000788:	6a46                	ld	s4,80(sp)
    8000078a:	6aa6                	ld	s5,72(sp)
    8000078c:	6b06                	ld	s6,64(sp)
    8000078e:	7be2                	ld	s7,56(sp)
    80000790:	7c42                	ld	s8,48(sp)
    80000792:	7ca2                	ld	s9,40(sp)
    80000794:	7d02                	ld	s10,32(sp)
    80000796:	6de2                	ld	s11,24(sp)
    80000798:	6129                	addi	sp,sp,192
    8000079a:	8082                	ret
    release(&pr.lock);
    8000079c:	00011517          	auipc	a0,0x11
    800007a0:	10c50513          	addi	a0,a0,268 # 800118a8 <pr>
    800007a4:	00000097          	auipc	ra,0x0
    800007a8:	3c4080e7          	jalr	964(ra) # 80000b68 <release>
}
    800007ac:	bfc9                	j	8000077e <printf+0x1b6>

00000000800007ae <printfinit>:
    ;
}

void
printfinit(void)
{
    800007ae:	1101                	addi	sp,sp,-32
    800007b0:	ec06                	sd	ra,24(sp)
    800007b2:	e822                	sd	s0,16(sp)
    800007b4:	e426                	sd	s1,8(sp)
    800007b6:	1000                	addi	s0,sp,32
  initlock(&pr.lock, "pr");
    800007b8:	00011497          	auipc	s1,0x11
    800007bc:	0f048493          	addi	s1,s1,240 # 800118a8 <pr>
    800007c0:	00007597          	auipc	a1,0x7
    800007c4:	98058593          	addi	a1,a1,-1664 # 80007140 <userret+0xb0>
    800007c8:	8526                	mv	a0,s1
    800007ca:	00000097          	auipc	ra,0x0
    800007ce:	228080e7          	jalr	552(ra) # 800009f2 <initlock>
  pr.locking = 1;
    800007d2:	4785                	li	a5,1
    800007d4:	cc9c                	sw	a5,24(s1)
}
    800007d6:	60e2                	ld	ra,24(sp)
    800007d8:	6442                	ld	s0,16(sp)
    800007da:	64a2                	ld	s1,8(sp)
    800007dc:	6105                	addi	sp,sp,32
    800007de:	8082                	ret

00000000800007e0 <uartinit>:
#define ReadReg(reg) (*(Reg(reg)))
#define WriteReg(reg, v) (*(Reg(reg)) = (v))

void
uartinit(void)
{
    800007e0:	1141                	addi	sp,sp,-16
    800007e2:	e422                	sd	s0,8(sp)
    800007e4:	0800                	addi	s0,sp,16
  // disable interrupts.
  WriteReg(IER, 0x00);
    800007e6:	100007b7          	lui	a5,0x10000
    800007ea:	000780a3          	sb	zero,1(a5) # 10000001 <_entry-0x6fffffff>

  // special mode to set baud rate.
  WriteReg(LCR, 0x80);
    800007ee:	f8000713          	li	a4,-128
    800007f2:	00e781a3          	sb	a4,3(a5)

  // LSB for baud rate of 38.4K.
  WriteReg(0, 0x03);
    800007f6:	470d                	li	a4,3
    800007f8:	00e78023          	sb	a4,0(a5)

  // MSB for baud rate of 38.4K.
  WriteReg(1, 0x00);
    800007fc:	000780a3          	sb	zero,1(a5)

  // leave set-baud mode,
  // and set word length to 8 bits, no parity.
  WriteReg(LCR, 0x03);
    80000800:	00e781a3          	sb	a4,3(a5)

  // reset and enable FIFOs.
  WriteReg(FCR, 0x07);
    80000804:	471d                	li	a4,7
    80000806:	00e78123          	sb	a4,2(a5)

  // enable receive interrupts.
  WriteReg(IER, 0x01);
    8000080a:	4705                	li	a4,1
    8000080c:	00e780a3          	sb	a4,1(a5)
}
    80000810:	6422                	ld	s0,8(sp)
    80000812:	0141                	addi	sp,sp,16
    80000814:	8082                	ret

0000000080000816 <uartputc>:

// write one output character to the UART.
void
uartputc(int c)
{
    80000816:	1141                	addi	sp,sp,-16
    80000818:	e422                	sd	s0,8(sp)
    8000081a:	0800                	addi	s0,sp,16
  // wait for Transmit Holding Empty to be set in LSR.
  while((ReadReg(LSR) & (1 << 5)) == 0)
    8000081c:	10000737          	lui	a4,0x10000
    80000820:	00574783          	lbu	a5,5(a4) # 10000005 <_entry-0x6ffffffb>
    80000824:	0ff7f793          	andi	a5,a5,255
    80000828:	0207f793          	andi	a5,a5,32
    8000082c:	dbf5                	beqz	a5,80000820 <uartputc+0xa>
    ;
  WriteReg(THR, c);
    8000082e:	0ff57513          	andi	a0,a0,255
    80000832:	100007b7          	lui	a5,0x10000
    80000836:	00a78023          	sb	a0,0(a5) # 10000000 <_entry-0x70000000>
}
    8000083a:	6422                	ld	s0,8(sp)
    8000083c:	0141                	addi	sp,sp,16
    8000083e:	8082                	ret

0000000080000840 <uartgetc>:

// read one input character from the UART.
// return -1 if none is waiting.
int
uartgetc(void)
{
    80000840:	1141                	addi	sp,sp,-16
    80000842:	e422                	sd	s0,8(sp)
    80000844:	0800                	addi	s0,sp,16
  if(ReadReg(LSR) & 0x01){
    80000846:	100007b7          	lui	a5,0x10000
    8000084a:	0057c783          	lbu	a5,5(a5) # 10000005 <_entry-0x6ffffffb>
    8000084e:	8b85                	andi	a5,a5,1
    80000850:	cb91                	beqz	a5,80000864 <uartgetc+0x24>
    // input data is ready.
    return ReadReg(RHR);
    80000852:	100007b7          	lui	a5,0x10000
    80000856:	0007c503          	lbu	a0,0(a5) # 10000000 <_entry-0x70000000>
    8000085a:	0ff57513          	andi	a0,a0,255
  } else {
    return -1;
  }
}
    8000085e:	6422                	ld	s0,8(sp)
    80000860:	0141                	addi	sp,sp,16
    80000862:	8082                	ret
    return -1;
    80000864:	557d                	li	a0,-1
    80000866:	bfe5                	j	8000085e <uartgetc+0x1e>

0000000080000868 <uartintr>:

// trap.c calls here when the uart interrupts.
void
uartintr(void)
{
    80000868:	1101                	addi	sp,sp,-32
    8000086a:	ec06                	sd	ra,24(sp)
    8000086c:	e822                	sd	s0,16(sp)
    8000086e:	e426                	sd	s1,8(sp)
    80000870:	1000                	addi	s0,sp,32
  while(1){
    int c = uartgetc();
    if(c == -1)
    80000872:	54fd                	li	s1,-1
    int c = uartgetc();
    80000874:	00000097          	auipc	ra,0x0
    80000878:	fcc080e7          	jalr	-52(ra) # 80000840 <uartgetc>
    if(c == -1)
    8000087c:	00950763          	beq	a0,s1,8000088a <uartintr+0x22>
      break;
    consoleintr(c);
    80000880:	00000097          	auipc	ra,0x0
    80000884:	a58080e7          	jalr	-1448(ra) # 800002d8 <consoleintr>
  while(1){
    80000888:	b7f5                	j	80000874 <uartintr+0xc>
  }
}
    8000088a:	60e2                	ld	ra,24(sp)
    8000088c:	6442                	ld	s0,16(sp)
    8000088e:	64a2                	ld	s1,8(sp)
    80000890:	6105                	addi	sp,sp,32
    80000892:	8082                	ret

0000000080000894 <kfree>:
// which normally should have been returned by a
// call to kalloc().  (The exception is when
// initializing the allocator; see kinit above.)
void
kfree(void *pa)
{
    80000894:	1101                	addi	sp,sp,-32
    80000896:	ec06                	sd	ra,24(sp)
    80000898:	e822                	sd	s0,16(sp)
    8000089a:	e426                	sd	s1,8(sp)
    8000089c:	e04a                	sd	s2,0(sp)
    8000089e:	1000                	addi	s0,sp,32
  struct run *r;

  if(((uint64)pa % PGSIZE) != 0 || (char*)pa < end || (uint64)pa >= PHYSTOP)
    800008a0:	6785                	lui	a5,0x1
    800008a2:	17fd                	addi	a5,a5,-1
    800008a4:	8fe9                	and	a5,a5,a0
    800008a6:	ebb9                	bnez	a5,800008fc <kfree+0x68>
    800008a8:	84aa                	mv	s1,a0
    800008aa:	00028797          	auipc	a5,0x28
    800008ae:	75678793          	addi	a5,a5,1878 # 80029000 <end>
    800008b2:	04f56563          	bltu	a0,a5,800008fc <kfree+0x68>
    800008b6:	47c5                	li	a5,17
    800008b8:	07ee                	slli	a5,a5,0x1b
    800008ba:	04f57163          	bleu	a5,a0,800008fc <kfree+0x68>
    panic("kfree");

  // Fill with junk to catch dangling refs.
  memset(pa, 1, PGSIZE);
    800008be:	6605                	lui	a2,0x1
    800008c0:	4585                	li	a1,1
    800008c2:	00000097          	auipc	ra,0x0
    800008c6:	304080e7          	jalr	772(ra) # 80000bc6 <memset>

  r = (struct run*)pa;

  acquire(&kmem.lock);
    800008ca:	00011917          	auipc	s2,0x11
    800008ce:	ffe90913          	addi	s2,s2,-2 # 800118c8 <kmem>
    800008d2:	854a                	mv	a0,s2
    800008d4:	00000097          	auipc	ra,0x0
    800008d8:	22c080e7          	jalr	556(ra) # 80000b00 <acquire>
  r->next = kmem.freelist;
    800008dc:	01893783          	ld	a5,24(s2)
    800008e0:	e09c                	sd	a5,0(s1)
  kmem.freelist = r;
    800008e2:	00993c23          	sd	s1,24(s2)
  release(&kmem.lock);
    800008e6:	854a                	mv	a0,s2
    800008e8:	00000097          	auipc	ra,0x0
    800008ec:	280080e7          	jalr	640(ra) # 80000b68 <release>
}
    800008f0:	60e2                	ld	ra,24(sp)
    800008f2:	6442                	ld	s0,16(sp)
    800008f4:	64a2                	ld	s1,8(sp)
    800008f6:	6902                	ld	s2,0(sp)
    800008f8:	6105                	addi	sp,sp,32
    800008fa:	8082                	ret
    panic("kfree");
    800008fc:	00007517          	auipc	a0,0x7
    80000900:	84c50513          	addi	a0,a0,-1972 # 80007148 <userret+0xb8>
    80000904:	00000097          	auipc	ra,0x0
    80000908:	c7a080e7          	jalr	-902(ra) # 8000057e <panic>

000000008000090c <freerange>:
{
    8000090c:	7179                	addi	sp,sp,-48
    8000090e:	f406                	sd	ra,40(sp)
    80000910:	f022                	sd	s0,32(sp)
    80000912:	ec26                	sd	s1,24(sp)
    80000914:	e84a                	sd	s2,16(sp)
    80000916:	e44e                	sd	s3,8(sp)
    80000918:	e052                	sd	s4,0(sp)
    8000091a:	1800                	addi	s0,sp,48
  p = (char*)PGROUNDUP((uint64)pa_start);
    8000091c:	6485                	lui	s1,0x1
    8000091e:	14fd                	addi	s1,s1,-1
    80000920:	94aa                	add	s1,s1,a0
    80000922:	757d                	lui	a0,0xfffff
    80000924:	8ce9                	and	s1,s1,a0
  for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
    80000926:	6509                	lui	a0,0x2
    80000928:	94aa                	add	s1,s1,a0
    8000092a:	0095ee63          	bltu	a1,s1,80000946 <freerange+0x3a>
    8000092e:	892e                	mv	s2,a1
    kfree(p);
    80000930:	7a7d                	lui	s4,0xfffff
  for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
    80000932:	6985                	lui	s3,0x1
    kfree(p);
    80000934:	01448533          	add	a0,s1,s4
    80000938:	00000097          	auipc	ra,0x0
    8000093c:	f5c080e7          	jalr	-164(ra) # 80000894 <kfree>
  for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
    80000940:	94ce                	add	s1,s1,s3
    80000942:	fe9979e3          	bleu	s1,s2,80000934 <freerange+0x28>
}
    80000946:	70a2                	ld	ra,40(sp)
    80000948:	7402                	ld	s0,32(sp)
    8000094a:	64e2                	ld	s1,24(sp)
    8000094c:	6942                	ld	s2,16(sp)
    8000094e:	69a2                	ld	s3,8(sp)
    80000950:	6a02                	ld	s4,0(sp)
    80000952:	6145                	addi	sp,sp,48
    80000954:	8082                	ret

0000000080000956 <kinit>:
{
    80000956:	1141                	addi	sp,sp,-16
    80000958:	e406                	sd	ra,8(sp)
    8000095a:	e022                	sd	s0,0(sp)
    8000095c:	0800                	addi	s0,sp,16
  initlock(&kmem.lock, "kmem");
    8000095e:	00006597          	auipc	a1,0x6
    80000962:	7f258593          	addi	a1,a1,2034 # 80007150 <userret+0xc0>
    80000966:	00011517          	auipc	a0,0x11
    8000096a:	f6250513          	addi	a0,a0,-158 # 800118c8 <kmem>
    8000096e:	00000097          	auipc	ra,0x0
    80000972:	084080e7          	jalr	132(ra) # 800009f2 <initlock>
  freerange(end, (void*)PHYSTOP);
    80000976:	45c5                	li	a1,17
    80000978:	05ee                	slli	a1,a1,0x1b
    8000097a:	00028517          	auipc	a0,0x28
    8000097e:	68650513          	addi	a0,a0,1670 # 80029000 <end>
    80000982:	00000097          	auipc	ra,0x0
    80000986:	f8a080e7          	jalr	-118(ra) # 8000090c <freerange>
}
    8000098a:	60a2                	ld	ra,8(sp)
    8000098c:	6402                	ld	s0,0(sp)
    8000098e:	0141                	addi	sp,sp,16
    80000990:	8082                	ret

0000000080000992 <kalloc>:
// Allocate one 4096-byte page of physical memory.
// Returns a pointer that the kernel can use.
// Returns 0 if the memory cannot be allocated.
void *
kalloc(void)
{
    80000992:	1101                	addi	sp,sp,-32
    80000994:	ec06                	sd	ra,24(sp)
    80000996:	e822                	sd	s0,16(sp)
    80000998:	e426                	sd	s1,8(sp)
    8000099a:	1000                	addi	s0,sp,32
  struct run *r;

  acquire(&kmem.lock);
    8000099c:	00011497          	auipc	s1,0x11
    800009a0:	f2c48493          	addi	s1,s1,-212 # 800118c8 <kmem>
    800009a4:	8526                	mv	a0,s1
    800009a6:	00000097          	auipc	ra,0x0
    800009aa:	15a080e7          	jalr	346(ra) # 80000b00 <acquire>
  r = kmem.freelist;
    800009ae:	6c84                	ld	s1,24(s1)
  if(r)
    800009b0:	c885                	beqz	s1,800009e0 <kalloc+0x4e>
    kmem.freelist = r->next;
    800009b2:	609c                	ld	a5,0(s1)
    800009b4:	00011517          	auipc	a0,0x11
    800009b8:	f1450513          	addi	a0,a0,-236 # 800118c8 <kmem>
    800009bc:	ed1c                	sd	a5,24(a0)
  release(&kmem.lock);
    800009be:	00000097          	auipc	ra,0x0
    800009c2:	1aa080e7          	jalr	426(ra) # 80000b68 <release>

  if(r)
    memset((char*)r, 5, PGSIZE); // fill with junk
    800009c6:	6605                	lui	a2,0x1
    800009c8:	4595                	li	a1,5
    800009ca:	8526                	mv	a0,s1
    800009cc:	00000097          	auipc	ra,0x0
    800009d0:	1fa080e7          	jalr	506(ra) # 80000bc6 <memset>
  return (void*)r;
}
    800009d4:	8526                	mv	a0,s1
    800009d6:	60e2                	ld	ra,24(sp)
    800009d8:	6442                	ld	s0,16(sp)
    800009da:	64a2                	ld	s1,8(sp)
    800009dc:	6105                	addi	sp,sp,32
    800009de:	8082                	ret
  release(&kmem.lock);
    800009e0:	00011517          	auipc	a0,0x11
    800009e4:	ee850513          	addi	a0,a0,-280 # 800118c8 <kmem>
    800009e8:	00000097          	auipc	ra,0x0
    800009ec:	180080e7          	jalr	384(ra) # 80000b68 <release>
  if(r)
    800009f0:	b7d5                	j	800009d4 <kalloc+0x42>

00000000800009f2 <initlock>:

uint64 ntest_and_set;

void
initlock(struct spinlock *lk, char *name)
{
    800009f2:	1141                	addi	sp,sp,-16
    800009f4:	e422                	sd	s0,8(sp)
    800009f6:	0800                	addi	s0,sp,16
  lk->name = name;
    800009f8:	e50c                	sd	a1,8(a0)
  lk->locked = 0;
    800009fa:	00052023          	sw	zero,0(a0)
  lk->cpu = 0;
    800009fe:	00053823          	sd	zero,16(a0)
}
    80000a02:	6422                	ld	s0,8(sp)
    80000a04:	0141                	addi	sp,sp,16
    80000a06:	8082                	ret

0000000080000a08 <push_off>:
// it takes two pop_off()s to undo two push_off()s.  Also, if interrupts
// are initially off, then push_off, pop_off leaves them off.

void
push_off(void)
{
    80000a08:	1101                	addi	sp,sp,-32
    80000a0a:	ec06                	sd	ra,24(sp)
    80000a0c:	e822                	sd	s0,16(sp)
    80000a0e:	e426                	sd	s1,8(sp)
    80000a10:	1000                	addi	s0,sp,32
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80000a12:	100024f3          	csrr	s1,sstatus
    80000a16:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() & ~SSTATUS_SIE);
    80000a1a:	9bf5                	andi	a5,a5,-3
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80000a1c:	10079073          	csrw	sstatus,a5
  int old = intr_get();

  intr_off();
  if(mycpu()->noff == 0)
    80000a20:	00001097          	auipc	ra,0x1
    80000a24:	e62080e7          	jalr	-414(ra) # 80001882 <mycpu>
    80000a28:	5d3c                	lw	a5,120(a0)
    80000a2a:	cf89                	beqz	a5,80000a44 <push_off+0x3c>
    mycpu()->intena = old;
  mycpu()->noff += 1;
    80000a2c:	00001097          	auipc	ra,0x1
    80000a30:	e56080e7          	jalr	-426(ra) # 80001882 <mycpu>
    80000a34:	5d3c                	lw	a5,120(a0)
    80000a36:	2785                	addiw	a5,a5,1
    80000a38:	dd3c                	sw	a5,120(a0)
}
    80000a3a:	60e2                	ld	ra,24(sp)
    80000a3c:	6442                	ld	s0,16(sp)
    80000a3e:	64a2                	ld	s1,8(sp)
    80000a40:	6105                	addi	sp,sp,32
    80000a42:	8082                	ret
    mycpu()->intena = old;
    80000a44:	00001097          	auipc	ra,0x1
    80000a48:	e3e080e7          	jalr	-450(ra) # 80001882 <mycpu>
  return (x & SSTATUS_SIE) != 0;
    80000a4c:	8085                	srli	s1,s1,0x1
    80000a4e:	8885                	andi	s1,s1,1
    80000a50:	dd64                	sw	s1,124(a0)
    80000a52:	bfe9                	j	80000a2c <push_off+0x24>

0000000080000a54 <pop_off>:

void
pop_off(void)
{
    80000a54:	1141                	addi	sp,sp,-16
    80000a56:	e406                	sd	ra,8(sp)
    80000a58:	e022                	sd	s0,0(sp)
    80000a5a:	0800                	addi	s0,sp,16
  struct cpu *c = mycpu();
    80000a5c:	00001097          	auipc	ra,0x1
    80000a60:	e26080e7          	jalr	-474(ra) # 80001882 <mycpu>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80000a64:	100027f3          	csrr	a5,sstatus
  return (x & SSTATUS_SIE) != 0;
    80000a68:	8b89                	andi	a5,a5,2
  if(intr_get())
    80000a6a:	eb9d                	bnez	a5,80000aa0 <pop_off+0x4c>
    panic("pop_off - interruptible");
  c->noff -= 1;
    80000a6c:	5d3c                	lw	a5,120(a0)
    80000a6e:	37fd                	addiw	a5,a5,-1
    80000a70:	0007871b          	sext.w	a4,a5
    80000a74:	dd3c                	sw	a5,120(a0)
  if(c->noff < 0)
    80000a76:	02074d63          	bltz	a4,80000ab0 <pop_off+0x5c>
    panic("pop_off");
  if(c->noff == 0 && c->intena)
    80000a7a:	ef19                	bnez	a4,80000a98 <pop_off+0x44>
    80000a7c:	5d7c                	lw	a5,124(a0)
    80000a7e:	cf89                	beqz	a5,80000a98 <pop_off+0x44>
  asm volatile("csrr %0, sie" : "=r" (x) );
    80000a80:	104027f3          	csrr	a5,sie
  w_sie(r_sie() | SIE_SEIE | SIE_STIE | SIE_SSIE);
    80000a84:	2227e793          	ori	a5,a5,546
  asm volatile("csrw sie, %0" : : "r" (x));
    80000a88:	10479073          	csrw	sie,a5
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80000a8c:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    80000a90:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80000a94:	10079073          	csrw	sstatus,a5
    intr_on();
}
    80000a98:	60a2                	ld	ra,8(sp)
    80000a9a:	6402                	ld	s0,0(sp)
    80000a9c:	0141                	addi	sp,sp,16
    80000a9e:	8082                	ret
    panic("pop_off - interruptible");
    80000aa0:	00006517          	auipc	a0,0x6
    80000aa4:	6b850513          	addi	a0,a0,1720 # 80007158 <userret+0xc8>
    80000aa8:	00000097          	auipc	ra,0x0
    80000aac:	ad6080e7          	jalr	-1322(ra) # 8000057e <panic>
    panic("pop_off");
    80000ab0:	00006517          	auipc	a0,0x6
    80000ab4:	6c050513          	addi	a0,a0,1728 # 80007170 <userret+0xe0>
    80000ab8:	00000097          	auipc	ra,0x0
    80000abc:	ac6080e7          	jalr	-1338(ra) # 8000057e <panic>

0000000080000ac0 <holding>:
{
    80000ac0:	1101                	addi	sp,sp,-32
    80000ac2:	ec06                	sd	ra,24(sp)
    80000ac4:	e822                	sd	s0,16(sp)
    80000ac6:	e426                	sd	s1,8(sp)
    80000ac8:	1000                	addi	s0,sp,32
    80000aca:	84aa                	mv	s1,a0
  push_off();
    80000acc:	00000097          	auipc	ra,0x0
    80000ad0:	f3c080e7          	jalr	-196(ra) # 80000a08 <push_off>
  r = (lk->locked && lk->cpu == mycpu());
    80000ad4:	409c                	lw	a5,0(s1)
    80000ad6:	ef81                	bnez	a5,80000aee <holding+0x2e>
    80000ad8:	4481                	li	s1,0
  pop_off();
    80000ada:	00000097          	auipc	ra,0x0
    80000ade:	f7a080e7          	jalr	-134(ra) # 80000a54 <pop_off>
}
    80000ae2:	8526                	mv	a0,s1
    80000ae4:	60e2                	ld	ra,24(sp)
    80000ae6:	6442                	ld	s0,16(sp)
    80000ae8:	64a2                	ld	s1,8(sp)
    80000aea:	6105                	addi	sp,sp,32
    80000aec:	8082                	ret
  r = (lk->locked && lk->cpu == mycpu());
    80000aee:	6884                	ld	s1,16(s1)
    80000af0:	00001097          	auipc	ra,0x1
    80000af4:	d92080e7          	jalr	-622(ra) # 80001882 <mycpu>
    80000af8:	8c89                	sub	s1,s1,a0
    80000afa:	0014b493          	seqz	s1,s1
    80000afe:	bff1                	j	80000ada <holding+0x1a>

0000000080000b00 <acquire>:
{
    80000b00:	1101                	addi	sp,sp,-32
    80000b02:	ec06                	sd	ra,24(sp)
    80000b04:	e822                	sd	s0,16(sp)
    80000b06:	e426                	sd	s1,8(sp)
    80000b08:	1000                	addi	s0,sp,32
    80000b0a:	84aa                	mv	s1,a0
  push_off(); // disable interrupts to avoid deadlock.
    80000b0c:	00000097          	auipc	ra,0x0
    80000b10:	efc080e7          	jalr	-260(ra) # 80000a08 <push_off>
  if(holding(lk))
    80000b14:	8526                	mv	a0,s1
    80000b16:	00000097          	auipc	ra,0x0
    80000b1a:	faa080e7          	jalr	-86(ra) # 80000ac0 <holding>
    80000b1e:	e10d                	bnez	a0,80000b40 <acquire+0x40>
  while(__sync_lock_test_and_set(&lk->locked, 1) != 0) {
    80000b20:	4685                	li	a3,1
     __sync_fetch_and_add(&ntest_and_set, 1);
    80000b22:	00028717          	auipc	a4,0x28
    80000b26:	4e670713          	addi	a4,a4,1254 # 80029008 <ntest_and_set>
    80000b2a:	4605                	li	a2,1
  while(__sync_lock_test_and_set(&lk->locked, 1) != 0) {
    80000b2c:	87b6                	mv	a5,a3
    80000b2e:	0cf4a7af          	amoswap.w.aq	a5,a5,(s1)
    80000b32:	2781                	sext.w	a5,a5
    80000b34:	cf91                	beqz	a5,80000b50 <acquire+0x50>
     __sync_fetch_and_add(&ntest_and_set, 1);
    80000b36:	0f50000f          	fence	iorw,ow
    80000b3a:	04c7302f          	amoadd.d.aq	zero,a2,(a4)
    80000b3e:	b7fd                	j	80000b2c <acquire+0x2c>
    panic("acquire");
    80000b40:	00006517          	auipc	a0,0x6
    80000b44:	63850513          	addi	a0,a0,1592 # 80007178 <userret+0xe8>
    80000b48:	00000097          	auipc	ra,0x0
    80000b4c:	a36080e7          	jalr	-1482(ra) # 8000057e <panic>
  __sync_synchronize();
    80000b50:	0ff0000f          	fence
  lk->cpu = mycpu();
    80000b54:	00001097          	auipc	ra,0x1
    80000b58:	d2e080e7          	jalr	-722(ra) # 80001882 <mycpu>
    80000b5c:	e888                	sd	a0,16(s1)
}
    80000b5e:	60e2                	ld	ra,24(sp)
    80000b60:	6442                	ld	s0,16(sp)
    80000b62:	64a2                	ld	s1,8(sp)
    80000b64:	6105                	addi	sp,sp,32
    80000b66:	8082                	ret

0000000080000b68 <release>:
{
    80000b68:	1101                	addi	sp,sp,-32
    80000b6a:	ec06                	sd	ra,24(sp)
    80000b6c:	e822                	sd	s0,16(sp)
    80000b6e:	e426                	sd	s1,8(sp)
    80000b70:	1000                	addi	s0,sp,32
    80000b72:	84aa                	mv	s1,a0
  if(!holding(lk))
    80000b74:	00000097          	auipc	ra,0x0
    80000b78:	f4c080e7          	jalr	-180(ra) # 80000ac0 <holding>
    80000b7c:	c115                	beqz	a0,80000ba0 <release+0x38>
  lk->cpu = 0;
    80000b7e:	0004b823          	sd	zero,16(s1)
  __sync_synchronize();
    80000b82:	0ff0000f          	fence
  __sync_lock_release(&lk->locked);
    80000b86:	0f50000f          	fence	iorw,ow
    80000b8a:	0804a02f          	amoswap.w	zero,zero,(s1)
  pop_off();
    80000b8e:	00000097          	auipc	ra,0x0
    80000b92:	ec6080e7          	jalr	-314(ra) # 80000a54 <pop_off>
}
    80000b96:	60e2                	ld	ra,24(sp)
    80000b98:	6442                	ld	s0,16(sp)
    80000b9a:	64a2                	ld	s1,8(sp)
    80000b9c:	6105                	addi	sp,sp,32
    80000b9e:	8082                	ret
    panic("release");
    80000ba0:	00006517          	auipc	a0,0x6
    80000ba4:	5e050513          	addi	a0,a0,1504 # 80007180 <userret+0xf0>
    80000ba8:	00000097          	auipc	ra,0x0
    80000bac:	9d6080e7          	jalr	-1578(ra) # 8000057e <panic>

0000000080000bb0 <sys_ntas>:

uint64
sys_ntas(void)
{
    80000bb0:	1141                	addi	sp,sp,-16
    80000bb2:	e422                	sd	s0,8(sp)
    80000bb4:	0800                	addi	s0,sp,16
  return ntest_and_set;
}
    80000bb6:	00028797          	auipc	a5,0x28
    80000bba:	45278793          	addi	a5,a5,1106 # 80029008 <ntest_and_set>
    80000bbe:	6388                	ld	a0,0(a5)
    80000bc0:	6422                	ld	s0,8(sp)
    80000bc2:	0141                	addi	sp,sp,16
    80000bc4:	8082                	ret

0000000080000bc6 <memset>:
#include "types.h"

void*
memset(void *dst, int c, uint n)
{
    80000bc6:	1141                	addi	sp,sp,-16
    80000bc8:	e422                	sd	s0,8(sp)
    80000bca:	0800                	addi	s0,sp,16
  char *cdst = (char *) dst;
  int i;
  for(i = 0; i < n; i++){
    80000bcc:	ce09                	beqz	a2,80000be6 <memset+0x20>
    80000bce:	87aa                	mv	a5,a0
    80000bd0:	fff6071b          	addiw	a4,a2,-1
    80000bd4:	1702                	slli	a4,a4,0x20
    80000bd6:	9301                	srli	a4,a4,0x20
    80000bd8:	0705                	addi	a4,a4,1
    80000bda:	972a                	add	a4,a4,a0
    cdst[i] = c;
    80000bdc:	00b78023          	sb	a1,0(a5)
  for(i = 0; i < n; i++){
    80000be0:	0785                	addi	a5,a5,1
    80000be2:	fee79de3          	bne	a5,a4,80000bdc <memset+0x16>
  }
  return dst;
}
    80000be6:	6422                	ld	s0,8(sp)
    80000be8:	0141                	addi	sp,sp,16
    80000bea:	8082                	ret

0000000080000bec <memcmp>:

int
memcmp(const void *v1, const void *v2, uint n)
{
    80000bec:	1141                	addi	sp,sp,-16
    80000bee:	e422                	sd	s0,8(sp)
    80000bf0:	0800                	addi	s0,sp,16
  const uchar *s1, *s2;

  s1 = v1;
  s2 = v2;
  while(n-- > 0){
    80000bf2:	ce15                	beqz	a2,80000c2e <memcmp+0x42>
    80000bf4:	fff6069b          	addiw	a3,a2,-1
    if(*s1 != *s2)
    80000bf8:	00054783          	lbu	a5,0(a0)
    80000bfc:	0005c703          	lbu	a4,0(a1)
    80000c00:	02e79063          	bne	a5,a4,80000c20 <memcmp+0x34>
    80000c04:	1682                	slli	a3,a3,0x20
    80000c06:	9281                	srli	a3,a3,0x20
    80000c08:	0685                	addi	a3,a3,1
    80000c0a:	96aa                	add	a3,a3,a0
      return *s1 - *s2;
    s1++, s2++;
    80000c0c:	0505                	addi	a0,a0,1
    80000c0e:	0585                	addi	a1,a1,1
  while(n-- > 0){
    80000c10:	00d50d63          	beq	a0,a3,80000c2a <memcmp+0x3e>
    if(*s1 != *s2)
    80000c14:	00054783          	lbu	a5,0(a0)
    80000c18:	0005c703          	lbu	a4,0(a1)
    80000c1c:	fee788e3          	beq	a5,a4,80000c0c <memcmp+0x20>
      return *s1 - *s2;
    80000c20:	40e7853b          	subw	a0,a5,a4
  }

  return 0;
}
    80000c24:	6422                	ld	s0,8(sp)
    80000c26:	0141                	addi	sp,sp,16
    80000c28:	8082                	ret
  return 0;
    80000c2a:	4501                	li	a0,0
    80000c2c:	bfe5                	j	80000c24 <memcmp+0x38>
    80000c2e:	4501                	li	a0,0
    80000c30:	bfd5                	j	80000c24 <memcmp+0x38>

0000000080000c32 <memmove>:

void*
memmove(void *dst, const void *src, uint n)
{
    80000c32:	1141                	addi	sp,sp,-16
    80000c34:	e422                	sd	s0,8(sp)
    80000c36:	0800                	addi	s0,sp,16
  const char *s;
  char *d;

  s = src;
  d = dst;
  if(s < d && s + n > d){
    80000c38:	00a5f963          	bleu	a0,a1,80000c4a <memmove+0x18>
    80000c3c:	02061713          	slli	a4,a2,0x20
    80000c40:	9301                	srli	a4,a4,0x20
    80000c42:	00e587b3          	add	a5,a1,a4
    80000c46:	02f56563          	bltu	a0,a5,80000c70 <memmove+0x3e>
    s += n;
    d += n;
    while(n-- > 0)
      *--d = *--s;
  } else
    while(n-- > 0)
    80000c4a:	fff6069b          	addiw	a3,a2,-1
    80000c4e:	ce11                	beqz	a2,80000c6a <memmove+0x38>
    80000c50:	1682                	slli	a3,a3,0x20
    80000c52:	9281                	srli	a3,a3,0x20
    80000c54:	0685                	addi	a3,a3,1
    80000c56:	96ae                	add	a3,a3,a1
    80000c58:	87aa                	mv	a5,a0
      *d++ = *s++;
    80000c5a:	0585                	addi	a1,a1,1
    80000c5c:	0785                	addi	a5,a5,1
    80000c5e:	fff5c703          	lbu	a4,-1(a1)
    80000c62:	fee78fa3          	sb	a4,-1(a5)
    while(n-- > 0)
    80000c66:	fed59ae3          	bne	a1,a3,80000c5a <memmove+0x28>

  return dst;
}
    80000c6a:	6422                	ld	s0,8(sp)
    80000c6c:	0141                	addi	sp,sp,16
    80000c6e:	8082                	ret
    d += n;
    80000c70:	972a                	add	a4,a4,a0
    while(n-- > 0)
    80000c72:	fff6069b          	addiw	a3,a2,-1
    80000c76:	da75                	beqz	a2,80000c6a <memmove+0x38>
    80000c78:	02069613          	slli	a2,a3,0x20
    80000c7c:	9201                	srli	a2,a2,0x20
    80000c7e:	fff64613          	not	a2,a2
    80000c82:	963e                	add	a2,a2,a5
      *--d = *--s;
    80000c84:	17fd                	addi	a5,a5,-1
    80000c86:	177d                	addi	a4,a4,-1
    80000c88:	0007c683          	lbu	a3,0(a5)
    80000c8c:	00d70023          	sb	a3,0(a4)
    while(n-- > 0)
    80000c90:	fef61ae3          	bne	a2,a5,80000c84 <memmove+0x52>
    80000c94:	bfd9                	j	80000c6a <memmove+0x38>

0000000080000c96 <memcpy>:

// memcpy exists to placate GCC.  Use memmove.
void*
memcpy(void *dst, const void *src, uint n)
{
    80000c96:	1141                	addi	sp,sp,-16
    80000c98:	e406                	sd	ra,8(sp)
    80000c9a:	e022                	sd	s0,0(sp)
    80000c9c:	0800                	addi	s0,sp,16
  return memmove(dst, src, n);
    80000c9e:	00000097          	auipc	ra,0x0
    80000ca2:	f94080e7          	jalr	-108(ra) # 80000c32 <memmove>
}
    80000ca6:	60a2                	ld	ra,8(sp)
    80000ca8:	6402                	ld	s0,0(sp)
    80000caa:	0141                	addi	sp,sp,16
    80000cac:	8082                	ret

0000000080000cae <strncmp>:

int
strncmp(const char *p, const char *q, uint n)
{
    80000cae:	1141                	addi	sp,sp,-16
    80000cb0:	e422                	sd	s0,8(sp)
    80000cb2:	0800                	addi	s0,sp,16
  while(n > 0 && *p && *p == *q)
    80000cb4:	c229                	beqz	a2,80000cf6 <strncmp+0x48>
    80000cb6:	00054783          	lbu	a5,0(a0)
    80000cba:	c795                	beqz	a5,80000ce6 <strncmp+0x38>
    80000cbc:	0005c703          	lbu	a4,0(a1)
    80000cc0:	02f71363          	bne	a4,a5,80000ce6 <strncmp+0x38>
    80000cc4:	fff6071b          	addiw	a4,a2,-1
    80000cc8:	1702                	slli	a4,a4,0x20
    80000cca:	9301                	srli	a4,a4,0x20
    80000ccc:	0705                	addi	a4,a4,1
    80000cce:	972a                	add	a4,a4,a0
    n--, p++, q++;
    80000cd0:	0505                	addi	a0,a0,1
    80000cd2:	0585                	addi	a1,a1,1
  while(n > 0 && *p && *p == *q)
    80000cd4:	02e50363          	beq	a0,a4,80000cfa <strncmp+0x4c>
    80000cd8:	00054783          	lbu	a5,0(a0)
    80000cdc:	c789                	beqz	a5,80000ce6 <strncmp+0x38>
    80000cde:	0005c683          	lbu	a3,0(a1)
    80000ce2:	fef687e3          	beq	a3,a5,80000cd0 <strncmp+0x22>
  if(n == 0)
    return 0;
  return (uchar)*p - (uchar)*q;
    80000ce6:	00054503          	lbu	a0,0(a0)
    80000cea:	0005c783          	lbu	a5,0(a1)
    80000cee:	9d1d                	subw	a0,a0,a5
}
    80000cf0:	6422                	ld	s0,8(sp)
    80000cf2:	0141                	addi	sp,sp,16
    80000cf4:	8082                	ret
    return 0;
    80000cf6:	4501                	li	a0,0
    80000cf8:	bfe5                	j	80000cf0 <strncmp+0x42>
    80000cfa:	4501                	li	a0,0
    80000cfc:	bfd5                	j	80000cf0 <strncmp+0x42>

0000000080000cfe <strncpy>:

char*
strncpy(char *s, const char *t, int n)
{
    80000cfe:	1141                	addi	sp,sp,-16
    80000d00:	e422                	sd	s0,8(sp)
    80000d02:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  while(n-- > 0 && (*s++ = *t++) != 0)
    80000d04:	872a                	mv	a4,a0
    80000d06:	a011                	j	80000d0a <strncpy+0xc>
    80000d08:	8636                	mv	a2,a3
    80000d0a:	fff6069b          	addiw	a3,a2,-1
    80000d0e:	00c05963          	blez	a2,80000d20 <strncpy+0x22>
    80000d12:	0705                	addi	a4,a4,1
    80000d14:	0005c783          	lbu	a5,0(a1)
    80000d18:	fef70fa3          	sb	a5,-1(a4)
    80000d1c:	0585                	addi	a1,a1,1
    80000d1e:	f7ed                	bnez	a5,80000d08 <strncpy+0xa>
    ;
  while(n-- > 0)
    80000d20:	00d05c63          	blez	a3,80000d38 <strncpy+0x3a>
    80000d24:	86ba                	mv	a3,a4
    *s++ = 0;
    80000d26:	0685                	addi	a3,a3,1
    80000d28:	fe068fa3          	sb	zero,-1(a3)
  while(n-- > 0)
    80000d2c:	fff6c793          	not	a5,a3
    80000d30:	9fb9                	addw	a5,a5,a4
    80000d32:	9fb1                	addw	a5,a5,a2
    80000d34:	fef049e3          	bgtz	a5,80000d26 <strncpy+0x28>
  return os;
}
    80000d38:	6422                	ld	s0,8(sp)
    80000d3a:	0141                	addi	sp,sp,16
    80000d3c:	8082                	ret

0000000080000d3e <safestrcpy>:

// Like strncpy but guaranteed to NUL-terminate.
char*
safestrcpy(char *s, const char *t, int n)
{
    80000d3e:	1141                	addi	sp,sp,-16
    80000d40:	e422                	sd	s0,8(sp)
    80000d42:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  if(n <= 0)
    80000d44:	02c05363          	blez	a2,80000d6a <safestrcpy+0x2c>
    80000d48:	fff6069b          	addiw	a3,a2,-1
    80000d4c:	1682                	slli	a3,a3,0x20
    80000d4e:	9281                	srli	a3,a3,0x20
    80000d50:	96ae                	add	a3,a3,a1
    80000d52:	87aa                	mv	a5,a0
    return os;
  while(--n > 0 && (*s++ = *t++) != 0)
    80000d54:	00d58963          	beq	a1,a3,80000d66 <safestrcpy+0x28>
    80000d58:	0585                	addi	a1,a1,1
    80000d5a:	0785                	addi	a5,a5,1
    80000d5c:	fff5c703          	lbu	a4,-1(a1)
    80000d60:	fee78fa3          	sb	a4,-1(a5)
    80000d64:	fb65                	bnez	a4,80000d54 <safestrcpy+0x16>
    ;
  *s = 0;
    80000d66:	00078023          	sb	zero,0(a5)
  return os;
}
    80000d6a:	6422                	ld	s0,8(sp)
    80000d6c:	0141                	addi	sp,sp,16
    80000d6e:	8082                	ret

0000000080000d70 <strlen>:

int
strlen(const char *s)
{
    80000d70:	1141                	addi	sp,sp,-16
    80000d72:	e422                	sd	s0,8(sp)
    80000d74:	0800                	addi	s0,sp,16
  int n;

  for(n = 0; s[n]; n++)
    80000d76:	00054783          	lbu	a5,0(a0)
    80000d7a:	cf91                	beqz	a5,80000d96 <strlen+0x26>
    80000d7c:	0505                	addi	a0,a0,1
    80000d7e:	87aa                	mv	a5,a0
    80000d80:	4685                	li	a3,1
    80000d82:	9e89                	subw	a3,a3,a0
    80000d84:	00f6853b          	addw	a0,a3,a5
    80000d88:	0785                	addi	a5,a5,1
    80000d8a:	fff7c703          	lbu	a4,-1(a5)
    80000d8e:	fb7d                	bnez	a4,80000d84 <strlen+0x14>
    ;
  return n;
}
    80000d90:	6422                	ld	s0,8(sp)
    80000d92:	0141                	addi	sp,sp,16
    80000d94:	8082                	ret
  for(n = 0; s[n]; n++)
    80000d96:	4501                	li	a0,0
    80000d98:	bfe5                	j	80000d90 <strlen+0x20>

0000000080000d9a <main>:
volatile static int started = 0;

// start() jumps here in supervisor mode on all CPUs.
void
main()
{
    80000d9a:	1141                	addi	sp,sp,-16
    80000d9c:	e406                	sd	ra,8(sp)
    80000d9e:	e022                	sd	s0,0(sp)
    80000da0:	0800                	addi	s0,sp,16
  if(cpuid() == 0){
    80000da2:	00001097          	auipc	ra,0x1
    80000da6:	ad0080e7          	jalr	-1328(ra) # 80001872 <cpuid>
    virtio_disk_init(minor(ROOTDEV)); // emulated hard disk
    userinit();      // first user process
    __sync_synchronize();
    started = 1;
  } else {
    while(started == 0)
    80000daa:	00028717          	auipc	a4,0x28
    80000dae:	26670713          	addi	a4,a4,614 # 80029010 <started>
  if(cpuid() == 0){
    80000db2:	c139                	beqz	a0,80000df8 <main+0x5e>
    while(started == 0)
    80000db4:	431c                	lw	a5,0(a4)
    80000db6:	2781                	sext.w	a5,a5
    80000db8:	dff5                	beqz	a5,80000db4 <main+0x1a>
      ;
    __sync_synchronize();
    80000dba:	0ff0000f          	fence
    printf("hart %d starting\n", cpuid());
    80000dbe:	00001097          	auipc	ra,0x1
    80000dc2:	ab4080e7          	jalr	-1356(ra) # 80001872 <cpuid>
    80000dc6:	85aa                	mv	a1,a0
    80000dc8:	00006517          	auipc	a0,0x6
    80000dcc:	3d850513          	addi	a0,a0,984 # 800071a0 <userret+0x110>
    80000dd0:	fffff097          	auipc	ra,0xfffff
    80000dd4:	7f8080e7          	jalr	2040(ra) # 800005c8 <printf>
    kvminithart();    // turn on paging
    80000dd8:	00000097          	auipc	ra,0x0
    80000ddc:	1ea080e7          	jalr	490(ra) # 80000fc2 <kvminithart>
    trapinithart();   // install kernel trap vector
    80000de0:	00001097          	auipc	ra,0x1
    80000de4:	6e2080e7          	jalr	1762(ra) # 800024c2 <trapinithart>
    plicinithart();   // ask PLIC for device interrupts
    80000de8:	00005097          	auipc	ra,0x5
    80000dec:	fb8080e7          	jalr	-72(ra) # 80005da0 <plicinithart>
  }

  scheduler();        
    80000df0:	00001097          	auipc	ra,0x1
    80000df4:	ff0080e7          	jalr	-16(ra) # 80001de0 <scheduler>
    consoleinit();
    80000df8:	fffff097          	auipc	ra,0xfffff
    80000dfc:	694080e7          	jalr	1684(ra) # 8000048c <consoleinit>
    printfinit();
    80000e00:	00000097          	auipc	ra,0x0
    80000e04:	9ae080e7          	jalr	-1618(ra) # 800007ae <printfinit>
    printf("\n");
    80000e08:	00006517          	auipc	a0,0x6
    80000e0c:	3a850513          	addi	a0,a0,936 # 800071b0 <userret+0x120>
    80000e10:	fffff097          	auipc	ra,0xfffff
    80000e14:	7b8080e7          	jalr	1976(ra) # 800005c8 <printf>
    printf("xv6 kernel is booting\n");
    80000e18:	00006517          	auipc	a0,0x6
    80000e1c:	37050513          	addi	a0,a0,880 # 80007188 <userret+0xf8>
    80000e20:	fffff097          	auipc	ra,0xfffff
    80000e24:	7a8080e7          	jalr	1960(ra) # 800005c8 <printf>
    printf("\n");
    80000e28:	00006517          	auipc	a0,0x6
    80000e2c:	38850513          	addi	a0,a0,904 # 800071b0 <userret+0x120>
    80000e30:	fffff097          	auipc	ra,0xfffff
    80000e34:	798080e7          	jalr	1944(ra) # 800005c8 <printf>
    kinit();         // physical page allocator
    80000e38:	00000097          	auipc	ra,0x0
    80000e3c:	b1e080e7          	jalr	-1250(ra) # 80000956 <kinit>
    kvminit();       // create kernel page table
    80000e40:	00000097          	auipc	ra,0x0
    80000e44:	306080e7          	jalr	774(ra) # 80001146 <kvminit>
    kvminithart();   // turn on paging
    80000e48:	00000097          	auipc	ra,0x0
    80000e4c:	17a080e7          	jalr	378(ra) # 80000fc2 <kvminithart>
    procinit();      // process table
    80000e50:	00001097          	auipc	ra,0x1
    80000e54:	952080e7          	jalr	-1710(ra) # 800017a2 <procinit>
    trapinit();      // trap vectors
    80000e58:	00001097          	auipc	ra,0x1
    80000e5c:	642080e7          	jalr	1602(ra) # 8000249a <trapinit>
    trapinithart();  // install kernel trap vector
    80000e60:	00001097          	auipc	ra,0x1
    80000e64:	662080e7          	jalr	1634(ra) # 800024c2 <trapinithart>
    plicinit();      // set up interrupt controller
    80000e68:	00005097          	auipc	ra,0x5
    80000e6c:	f22080e7          	jalr	-222(ra) # 80005d8a <plicinit>
    plicinithart();  // ask PLIC for device interrupts
    80000e70:	00005097          	auipc	ra,0x5
    80000e74:	f30080e7          	jalr	-208(ra) # 80005da0 <plicinithart>
    binit();         // buffer cache
    80000e78:	00002097          	auipc	ra,0x2
    80000e7c:	d7e080e7          	jalr	-642(ra) # 80002bf6 <binit>
    iinit();         // inode cache
    80000e80:	00002097          	auipc	ra,0x2
    80000e84:	454080e7          	jalr	1108(ra) # 800032d4 <iinit>
    fileinit();      // file table
    80000e88:	00003097          	auipc	ra,0x3
    80000e8c:	65a080e7          	jalr	1626(ra) # 800044e2 <fileinit>
    virtio_disk_init(minor(ROOTDEV)); // emulated hard disk
    80000e90:	4501                	li	a0,0
    80000e92:	00005097          	auipc	ra,0x5
    80000e96:	040080e7          	jalr	64(ra) # 80005ed2 <virtio_disk_init>
    userinit();      // first user process
    80000e9a:	00001097          	auipc	ra,0x1
    80000e9e:	c76080e7          	jalr	-906(ra) # 80001b10 <userinit>
    __sync_synchronize();
    80000ea2:	0ff0000f          	fence
    started = 1;
    80000ea6:	4785                	li	a5,1
    80000ea8:	00028717          	auipc	a4,0x28
    80000eac:	16f72423          	sw	a5,360(a4) # 80029010 <started>
    80000eb0:	b781                	j	80000df0 <main+0x56>

0000000080000eb2 <walk>:
//   21..39 -- 9 bits of level-1 index.
//   12..20 -- 9 bits of level-0 index.
//    0..12 -- 12 bits of byte offset within the page.
static pte_t *
walk(pagetable_t pagetable, uint64 va, int alloc)
{
    80000eb2:	7139                	addi	sp,sp,-64
    80000eb4:	fc06                	sd	ra,56(sp)
    80000eb6:	f822                	sd	s0,48(sp)
    80000eb8:	f426                	sd	s1,40(sp)
    80000eba:	f04a                	sd	s2,32(sp)
    80000ebc:	ec4e                	sd	s3,24(sp)
    80000ebe:	e852                	sd	s4,16(sp)
    80000ec0:	e456                	sd	s5,8(sp)
    80000ec2:	e05a                	sd	s6,0(sp)
    80000ec4:	0080                	addi	s0,sp,64
    80000ec6:	84aa                	mv	s1,a0
    80000ec8:	89ae                	mv	s3,a1
    80000eca:	8b32                	mv	s6,a2
  if(va >= MAXVA)
    80000ecc:	57fd                	li	a5,-1
    80000ece:	83e9                	srli	a5,a5,0x1a
    80000ed0:	4a79                	li	s4,30
    panic("walk");

  for(int level = 2; level > 0; level--) {
    80000ed2:	4ab1                	li	s5,12
  if(va >= MAXVA)
    80000ed4:	04b7f263          	bleu	a1,a5,80000f18 <walk+0x66>
    panic("walk");
    80000ed8:	00006517          	auipc	a0,0x6
    80000edc:	2e050513          	addi	a0,a0,736 # 800071b8 <userret+0x128>
    80000ee0:	fffff097          	auipc	ra,0xfffff
    80000ee4:	69e080e7          	jalr	1694(ra) # 8000057e <panic>
    pte_t *pte = &pagetable[PX(level, va)];
    if(*pte & PTE_V) {
      pagetable = (pagetable_t)PTE2PA(*pte);
    } else {
      if(!alloc || (pagetable = (pde_t*)kalloc()) == 0)
    80000ee8:	060b0663          	beqz	s6,80000f54 <walk+0xa2>
    80000eec:	00000097          	auipc	ra,0x0
    80000ef0:	aa6080e7          	jalr	-1370(ra) # 80000992 <kalloc>
    80000ef4:	84aa                	mv	s1,a0
    80000ef6:	c529                	beqz	a0,80000f40 <walk+0x8e>
        return 0;
      memset(pagetable, 0, PGSIZE);
    80000ef8:	6605                	lui	a2,0x1
    80000efa:	4581                	li	a1,0
    80000efc:	00000097          	auipc	ra,0x0
    80000f00:	cca080e7          	jalr	-822(ra) # 80000bc6 <memset>
      *pte = PA2PTE(pagetable) | PTE_V;
    80000f04:	00c4d793          	srli	a5,s1,0xc
    80000f08:	07aa                	slli	a5,a5,0xa
    80000f0a:	0017e793          	ori	a5,a5,1
    80000f0e:	00f93023          	sd	a5,0(s2)
  for(int level = 2; level > 0; level--) {
    80000f12:	3a5d                	addiw	s4,s4,-9
    80000f14:	035a0063          	beq	s4,s5,80000f34 <walk+0x82>
    pte_t *pte = &pagetable[PX(level, va)];
    80000f18:	0149d933          	srl	s2,s3,s4
    80000f1c:	1ff97913          	andi	s2,s2,511
    80000f20:	090e                	slli	s2,s2,0x3
    80000f22:	9926                	add	s2,s2,s1
    if(*pte & PTE_V) {
    80000f24:	00093483          	ld	s1,0(s2)
    80000f28:	0014f793          	andi	a5,s1,1
    80000f2c:	dfd5                	beqz	a5,80000ee8 <walk+0x36>
      pagetable = (pagetable_t)PTE2PA(*pte);
    80000f2e:	80a9                	srli	s1,s1,0xa
    80000f30:	04b2                	slli	s1,s1,0xc
    80000f32:	b7c5                	j	80000f12 <walk+0x60>
    }
  }
  return &pagetable[PX(0, va)];
    80000f34:	00c9d513          	srli	a0,s3,0xc
    80000f38:	1ff57513          	andi	a0,a0,511
    80000f3c:	050e                	slli	a0,a0,0x3
    80000f3e:	9526                	add	a0,a0,s1
}
    80000f40:	70e2                	ld	ra,56(sp)
    80000f42:	7442                	ld	s0,48(sp)
    80000f44:	74a2                	ld	s1,40(sp)
    80000f46:	7902                	ld	s2,32(sp)
    80000f48:	69e2                	ld	s3,24(sp)
    80000f4a:	6a42                	ld	s4,16(sp)
    80000f4c:	6aa2                	ld	s5,8(sp)
    80000f4e:	6b02                	ld	s6,0(sp)
    80000f50:	6121                	addi	sp,sp,64
    80000f52:	8082                	ret
        return 0;
    80000f54:	4501                	li	a0,0
    80000f56:	b7ed                	j	80000f40 <walk+0x8e>

0000000080000f58 <freewalk>:

// Recursively free page-table pages.
// All leaf mappings must already have been removed.
static void
freewalk(pagetable_t pagetable)
{
    80000f58:	7179                	addi	sp,sp,-48
    80000f5a:	f406                	sd	ra,40(sp)
    80000f5c:	f022                	sd	s0,32(sp)
    80000f5e:	ec26                	sd	s1,24(sp)
    80000f60:	e84a                	sd	s2,16(sp)
    80000f62:	e44e                	sd	s3,8(sp)
    80000f64:	e052                	sd	s4,0(sp)
    80000f66:	1800                	addi	s0,sp,48
    80000f68:	8a2a                	mv	s4,a0
  // there are 2^9 = 512 PTEs in a page table.
  for(int i = 0; i < 512; i++){
    80000f6a:	84aa                	mv	s1,a0
    80000f6c:	6905                	lui	s2,0x1
    80000f6e:	992a                	add	s2,s2,a0
    pte_t pte = pagetable[i];
    if((pte & PTE_V) && (pte & (PTE_R|PTE_W|PTE_X)) == 0){
    80000f70:	4985                	li	s3,1
    80000f72:	a821                	j	80000f8a <freewalk+0x32>
      // this PTE points to a lower-level page table.
      uint64 child = PTE2PA(pte);
    80000f74:	8129                	srli	a0,a0,0xa
      freewalk((pagetable_t)child);
    80000f76:	0532                	slli	a0,a0,0xc
    80000f78:	00000097          	auipc	ra,0x0
    80000f7c:	fe0080e7          	jalr	-32(ra) # 80000f58 <freewalk>
      pagetable[i] = 0;
    80000f80:	0004b023          	sd	zero,0(s1)
  for(int i = 0; i < 512; i++){
    80000f84:	04a1                	addi	s1,s1,8
    80000f86:	03248163          	beq	s1,s2,80000fa8 <freewalk+0x50>
    pte_t pte = pagetable[i];
    80000f8a:	6088                	ld	a0,0(s1)
    if((pte & PTE_V) && (pte & (PTE_R|PTE_W|PTE_X)) == 0){
    80000f8c:	00f57793          	andi	a5,a0,15
    80000f90:	ff3782e3          	beq	a5,s3,80000f74 <freewalk+0x1c>
    } else if(pte & PTE_V){
    80000f94:	8905                	andi	a0,a0,1
    80000f96:	d57d                	beqz	a0,80000f84 <freewalk+0x2c>
      panic("freewalk: leaf");
    80000f98:	00006517          	auipc	a0,0x6
    80000f9c:	22850513          	addi	a0,a0,552 # 800071c0 <userret+0x130>
    80000fa0:	fffff097          	auipc	ra,0xfffff
    80000fa4:	5de080e7          	jalr	1502(ra) # 8000057e <panic>
    }
  }
  kfree((void*)pagetable);
    80000fa8:	8552                	mv	a0,s4
    80000faa:	00000097          	auipc	ra,0x0
    80000fae:	8ea080e7          	jalr	-1814(ra) # 80000894 <kfree>
}
    80000fb2:	70a2                	ld	ra,40(sp)
    80000fb4:	7402                	ld	s0,32(sp)
    80000fb6:	64e2                	ld	s1,24(sp)
    80000fb8:	6942                	ld	s2,16(sp)
    80000fba:	69a2                	ld	s3,8(sp)
    80000fbc:	6a02                	ld	s4,0(sp)
    80000fbe:	6145                	addi	sp,sp,48
    80000fc0:	8082                	ret

0000000080000fc2 <kvminithart>:
{
    80000fc2:	1141                	addi	sp,sp,-16
    80000fc4:	e422                	sd	s0,8(sp)
    80000fc6:	0800                	addi	s0,sp,16
  w_satp(MAKE_SATP(kernel_pagetable));
    80000fc8:	00028797          	auipc	a5,0x28
    80000fcc:	05078793          	addi	a5,a5,80 # 80029018 <kernel_pagetable>
    80000fd0:	639c                	ld	a5,0(a5)
    80000fd2:	83b1                	srli	a5,a5,0xc
    80000fd4:	577d                	li	a4,-1
    80000fd6:	177e                	slli	a4,a4,0x3f
    80000fd8:	8fd9                	or	a5,a5,a4
  asm volatile("csrw satp, %0" : : "r" (x));
    80000fda:	18079073          	csrw	satp,a5
// flush the TLB.
static inline void
sfence_vma()
{
  // the zero, zero means flush all TLB entries.
  asm volatile("sfence.vma zero, zero");
    80000fde:	12000073          	sfence.vma
}
    80000fe2:	6422                	ld	s0,8(sp)
    80000fe4:	0141                	addi	sp,sp,16
    80000fe6:	8082                	ret

0000000080000fe8 <walkaddr>:
{
    80000fe8:	1141                	addi	sp,sp,-16
    80000fea:	e406                	sd	ra,8(sp)
    80000fec:	e022                	sd	s0,0(sp)
    80000fee:	0800                	addi	s0,sp,16
  pte = walk(pagetable, va, 0);
    80000ff0:	4601                	li	a2,0
    80000ff2:	00000097          	auipc	ra,0x0
    80000ff6:	ec0080e7          	jalr	-320(ra) # 80000eb2 <walk>
  if(pte == 0)
    80000ffa:	c105                	beqz	a0,8000101a <walkaddr+0x32>
  if((*pte & PTE_V) == 0)
    80000ffc:	611c                	ld	a5,0(a0)
  if((*pte & PTE_U) == 0)
    80000ffe:	0117f693          	andi	a3,a5,17
    80001002:	4745                	li	a4,17
    return 0;
    80001004:	4501                	li	a0,0
  if((*pte & PTE_U) == 0)
    80001006:	00e68663          	beq	a3,a4,80001012 <walkaddr+0x2a>
}
    8000100a:	60a2                	ld	ra,8(sp)
    8000100c:	6402                	ld	s0,0(sp)
    8000100e:	0141                	addi	sp,sp,16
    80001010:	8082                	ret
  pa = PTE2PA(*pte);
    80001012:	83a9                	srli	a5,a5,0xa
    80001014:	00c79513          	slli	a0,a5,0xc
  return pa;
    80001018:	bfcd                	j	8000100a <walkaddr+0x22>
    return 0;
    8000101a:	4501                	li	a0,0
    8000101c:	b7fd                	j	8000100a <walkaddr+0x22>

000000008000101e <kvmpa>:
{
    8000101e:	1101                	addi	sp,sp,-32
    80001020:	ec06                	sd	ra,24(sp)
    80001022:	e822                	sd	s0,16(sp)
    80001024:	e426                	sd	s1,8(sp)
    80001026:	1000                	addi	s0,sp,32
    80001028:	85aa                	mv	a1,a0
  uint64 off = va % PGSIZE;
    8000102a:	6785                	lui	a5,0x1
    8000102c:	17fd                	addi	a5,a5,-1
    8000102e:	00f574b3          	and	s1,a0,a5
  pte = walk(kernel_pagetable, va, 0);
    80001032:	4601                	li	a2,0
    80001034:	00028797          	auipc	a5,0x28
    80001038:	fe478793          	addi	a5,a5,-28 # 80029018 <kernel_pagetable>
    8000103c:	6388                	ld	a0,0(a5)
    8000103e:	00000097          	auipc	ra,0x0
    80001042:	e74080e7          	jalr	-396(ra) # 80000eb2 <walk>
  if(pte == 0)
    80001046:	cd09                	beqz	a0,80001060 <kvmpa+0x42>
  if((*pte & PTE_V) == 0)
    80001048:	6108                	ld	a0,0(a0)
    8000104a:	00157793          	andi	a5,a0,1
    8000104e:	c38d                	beqz	a5,80001070 <kvmpa+0x52>
  pa = PTE2PA(*pte);
    80001050:	8129                	srli	a0,a0,0xa
    80001052:	0532                	slli	a0,a0,0xc
}
    80001054:	9526                	add	a0,a0,s1
    80001056:	60e2                	ld	ra,24(sp)
    80001058:	6442                	ld	s0,16(sp)
    8000105a:	64a2                	ld	s1,8(sp)
    8000105c:	6105                	addi	sp,sp,32
    8000105e:	8082                	ret
    panic("kvmpa");
    80001060:	00006517          	auipc	a0,0x6
    80001064:	17050513          	addi	a0,a0,368 # 800071d0 <userret+0x140>
    80001068:	fffff097          	auipc	ra,0xfffff
    8000106c:	516080e7          	jalr	1302(ra) # 8000057e <panic>
    panic("kvmpa");
    80001070:	00006517          	auipc	a0,0x6
    80001074:	16050513          	addi	a0,a0,352 # 800071d0 <userret+0x140>
    80001078:	fffff097          	auipc	ra,0xfffff
    8000107c:	506080e7          	jalr	1286(ra) # 8000057e <panic>

0000000080001080 <mappages>:
{
    80001080:	715d                	addi	sp,sp,-80
    80001082:	e486                	sd	ra,72(sp)
    80001084:	e0a2                	sd	s0,64(sp)
    80001086:	fc26                	sd	s1,56(sp)
    80001088:	f84a                	sd	s2,48(sp)
    8000108a:	f44e                	sd	s3,40(sp)
    8000108c:	f052                	sd	s4,32(sp)
    8000108e:	ec56                	sd	s5,24(sp)
    80001090:	e85a                	sd	s6,16(sp)
    80001092:	e45e                	sd	s7,8(sp)
    80001094:	0880                	addi	s0,sp,80
    80001096:	8aaa                	mv	s5,a0
    80001098:	8b3a                	mv	s6,a4
  a = PGROUNDDOWN(va);
    8000109a:	79fd                	lui	s3,0xfffff
    8000109c:	0135fa33          	and	s4,a1,s3
  last = PGROUNDDOWN(va + size - 1);
    800010a0:	167d                	addi	a2,a2,-1
    800010a2:	962e                	add	a2,a2,a1
    800010a4:	013679b3          	and	s3,a2,s3
  a = PGROUNDDOWN(va);
    800010a8:	8952                	mv	s2,s4
    800010aa:	41468a33          	sub	s4,a3,s4
    a += PGSIZE;
    800010ae:	6b85                	lui	s7,0x1
    800010b0:	a811                	j	800010c4 <mappages+0x44>
      panic("remap");
    800010b2:	00006517          	auipc	a0,0x6
    800010b6:	12650513          	addi	a0,a0,294 # 800071d8 <userret+0x148>
    800010ba:	fffff097          	auipc	ra,0xfffff
    800010be:	4c4080e7          	jalr	1220(ra) # 8000057e <panic>
    a += PGSIZE;
    800010c2:	995e                	add	s2,s2,s7
  for(;;){
    800010c4:	012a04b3          	add	s1,s4,s2
    if((pte = walk(pagetable, a, 1)) == 0)
    800010c8:	4605                	li	a2,1
    800010ca:	85ca                	mv	a1,s2
    800010cc:	8556                	mv	a0,s5
    800010ce:	00000097          	auipc	ra,0x0
    800010d2:	de4080e7          	jalr	-540(ra) # 80000eb2 <walk>
    800010d6:	cd19                	beqz	a0,800010f4 <mappages+0x74>
    if(*pte & PTE_V)
    800010d8:	611c                	ld	a5,0(a0)
    800010da:	8b85                	andi	a5,a5,1
    800010dc:	fbf9                	bnez	a5,800010b2 <mappages+0x32>
    *pte = PA2PTE(pa) | perm | PTE_V;
    800010de:	80b1                	srli	s1,s1,0xc
    800010e0:	04aa                	slli	s1,s1,0xa
    800010e2:	0164e4b3          	or	s1,s1,s6
    800010e6:	0014e493          	ori	s1,s1,1
    800010ea:	e104                	sd	s1,0(a0)
    if(a == last)
    800010ec:	fd391be3          	bne	s2,s3,800010c2 <mappages+0x42>
  return 0;
    800010f0:	4501                	li	a0,0
    800010f2:	a011                	j	800010f6 <mappages+0x76>
      return -1;
    800010f4:	557d                	li	a0,-1
}
    800010f6:	60a6                	ld	ra,72(sp)
    800010f8:	6406                	ld	s0,64(sp)
    800010fa:	74e2                	ld	s1,56(sp)
    800010fc:	7942                	ld	s2,48(sp)
    800010fe:	79a2                	ld	s3,40(sp)
    80001100:	7a02                	ld	s4,32(sp)
    80001102:	6ae2                	ld	s5,24(sp)
    80001104:	6b42                	ld	s6,16(sp)
    80001106:	6ba2                	ld	s7,8(sp)
    80001108:	6161                	addi	sp,sp,80
    8000110a:	8082                	ret

000000008000110c <kvmmap>:
{
    8000110c:	1141                	addi	sp,sp,-16
    8000110e:	e406                	sd	ra,8(sp)
    80001110:	e022                	sd	s0,0(sp)
    80001112:	0800                	addi	s0,sp,16
  if(mappages(kernel_pagetable, va, sz, pa, perm) != 0)
    80001114:	8736                	mv	a4,a3
    80001116:	86ae                	mv	a3,a1
    80001118:	85aa                	mv	a1,a0
    8000111a:	00028797          	auipc	a5,0x28
    8000111e:	efe78793          	addi	a5,a5,-258 # 80029018 <kernel_pagetable>
    80001122:	6388                	ld	a0,0(a5)
    80001124:	00000097          	auipc	ra,0x0
    80001128:	f5c080e7          	jalr	-164(ra) # 80001080 <mappages>
    8000112c:	e509                	bnez	a0,80001136 <kvmmap+0x2a>
}
    8000112e:	60a2                	ld	ra,8(sp)
    80001130:	6402                	ld	s0,0(sp)
    80001132:	0141                	addi	sp,sp,16
    80001134:	8082                	ret
    panic("kvmmap");
    80001136:	00006517          	auipc	a0,0x6
    8000113a:	0aa50513          	addi	a0,a0,170 # 800071e0 <userret+0x150>
    8000113e:	fffff097          	auipc	ra,0xfffff
    80001142:	440080e7          	jalr	1088(ra) # 8000057e <panic>

0000000080001146 <kvminit>:
{
    80001146:	1101                	addi	sp,sp,-32
    80001148:	ec06                	sd	ra,24(sp)
    8000114a:	e822                	sd	s0,16(sp)
    8000114c:	e426                	sd	s1,8(sp)
    8000114e:	1000                	addi	s0,sp,32
  kernel_pagetable = (pagetable_t) kalloc();
    80001150:	00000097          	auipc	ra,0x0
    80001154:	842080e7          	jalr	-1982(ra) # 80000992 <kalloc>
    80001158:	00028797          	auipc	a5,0x28
    8000115c:	eca7b023          	sd	a0,-320(a5) # 80029018 <kernel_pagetable>
  memset(kernel_pagetable, 0, PGSIZE);
    80001160:	6605                	lui	a2,0x1
    80001162:	4581                	li	a1,0
    80001164:	00000097          	auipc	ra,0x0
    80001168:	a62080e7          	jalr	-1438(ra) # 80000bc6 <memset>
  kvmmap(UART0, UART0, PGSIZE, PTE_R | PTE_W);
    8000116c:	4699                	li	a3,6
    8000116e:	6605                	lui	a2,0x1
    80001170:	100005b7          	lui	a1,0x10000
    80001174:	10000537          	lui	a0,0x10000
    80001178:	00000097          	auipc	ra,0x0
    8000117c:	f94080e7          	jalr	-108(ra) # 8000110c <kvmmap>
  kvmmap(VIRTION(0), VIRTION(0), PGSIZE, PTE_R | PTE_W);
    80001180:	4699                	li	a3,6
    80001182:	6605                	lui	a2,0x1
    80001184:	100015b7          	lui	a1,0x10001
    80001188:	10001537          	lui	a0,0x10001
    8000118c:	00000097          	auipc	ra,0x0
    80001190:	f80080e7          	jalr	-128(ra) # 8000110c <kvmmap>
  kvmmap(VIRTION(1), VIRTION(1), PGSIZE, PTE_R | PTE_W);
    80001194:	4699                	li	a3,6
    80001196:	6605                	lui	a2,0x1
    80001198:	100025b7          	lui	a1,0x10002
    8000119c:	10002537          	lui	a0,0x10002
    800011a0:	00000097          	auipc	ra,0x0
    800011a4:	f6c080e7          	jalr	-148(ra) # 8000110c <kvmmap>
  kvmmap(CLINT, CLINT, 0x10000, PTE_R | PTE_W);
    800011a8:	4699                	li	a3,6
    800011aa:	6641                	lui	a2,0x10
    800011ac:	020005b7          	lui	a1,0x2000
    800011b0:	02000537          	lui	a0,0x2000
    800011b4:	00000097          	auipc	ra,0x0
    800011b8:	f58080e7          	jalr	-168(ra) # 8000110c <kvmmap>
  kvmmap(PLIC, PLIC, 0x400000, PTE_R | PTE_W);
    800011bc:	4699                	li	a3,6
    800011be:	00400637          	lui	a2,0x400
    800011c2:	0c0005b7          	lui	a1,0xc000
    800011c6:	0c000537          	lui	a0,0xc000
    800011ca:	00000097          	auipc	ra,0x0
    800011ce:	f42080e7          	jalr	-190(ra) # 8000110c <kvmmap>
  kvmmap(KERNBASE, KERNBASE, (uint64)etext-KERNBASE, PTE_R | PTE_X);
    800011d2:	00007497          	auipc	s1,0x7
    800011d6:	e2e48493          	addi	s1,s1,-466 # 80008000 <initcode>
    800011da:	46a9                	li	a3,10
    800011dc:	80007617          	auipc	a2,0x80007
    800011e0:	e2460613          	addi	a2,a2,-476 # 8000 <_entry-0x7fff8000>
    800011e4:	4585                	li	a1,1
    800011e6:	05fe                	slli	a1,a1,0x1f
    800011e8:	852e                	mv	a0,a1
    800011ea:	00000097          	auipc	ra,0x0
    800011ee:	f22080e7          	jalr	-222(ra) # 8000110c <kvmmap>
  kvmmap((uint64)etext, (uint64)etext, PHYSTOP-(uint64)etext, PTE_R | PTE_W);
    800011f2:	4699                	li	a3,6
    800011f4:	4645                	li	a2,17
    800011f6:	066e                	slli	a2,a2,0x1b
    800011f8:	8e05                	sub	a2,a2,s1
    800011fa:	85a6                	mv	a1,s1
    800011fc:	8526                	mv	a0,s1
    800011fe:	00000097          	auipc	ra,0x0
    80001202:	f0e080e7          	jalr	-242(ra) # 8000110c <kvmmap>
  kvmmap(TRAMPOLINE, (uint64)trampoline, PGSIZE, PTE_R | PTE_X);
    80001206:	46a9                	li	a3,10
    80001208:	6605                	lui	a2,0x1
    8000120a:	00006597          	auipc	a1,0x6
    8000120e:	df658593          	addi	a1,a1,-522 # 80007000 <trampoline>
    80001212:	04000537          	lui	a0,0x4000
    80001216:	157d                	addi	a0,a0,-1
    80001218:	0532                	slli	a0,a0,0xc
    8000121a:	00000097          	auipc	ra,0x0
    8000121e:	ef2080e7          	jalr	-270(ra) # 8000110c <kvmmap>
}
    80001222:	60e2                	ld	ra,24(sp)
    80001224:	6442                	ld	s0,16(sp)
    80001226:	64a2                	ld	s1,8(sp)
    80001228:	6105                	addi	sp,sp,32
    8000122a:	8082                	ret

000000008000122c <uvmunmap>:
{
    8000122c:	715d                	addi	sp,sp,-80
    8000122e:	e486                	sd	ra,72(sp)
    80001230:	e0a2                	sd	s0,64(sp)
    80001232:	fc26                	sd	s1,56(sp)
    80001234:	f84a                	sd	s2,48(sp)
    80001236:	f44e                	sd	s3,40(sp)
    80001238:	f052                	sd	s4,32(sp)
    8000123a:	ec56                	sd	s5,24(sp)
    8000123c:	e85a                	sd	s6,16(sp)
    8000123e:	e45e                	sd	s7,8(sp)
    80001240:	0880                	addi	s0,sp,80
    80001242:	8a2a                	mv	s4,a0
    80001244:	8ab6                	mv	s5,a3
  a = PGROUNDDOWN(va);
    80001246:	79fd                	lui	s3,0xfffff
    80001248:	0135f933          	and	s2,a1,s3
  last = PGROUNDDOWN(va + size - 1);
    8000124c:	167d                	addi	a2,a2,-1
    8000124e:	962e                	add	a2,a2,a1
    80001250:	013679b3          	and	s3,a2,s3
    if(PTE_FLAGS(*pte) == PTE_V)
    80001254:	4b05                	li	s6,1
    a += PGSIZE;
    80001256:	6b85                	lui	s7,0x1
    80001258:	a8b1                	j	800012b4 <uvmunmap+0x88>
      panic("uvmunmap: walk");
    8000125a:	00006517          	auipc	a0,0x6
    8000125e:	f8e50513          	addi	a0,a0,-114 # 800071e8 <userret+0x158>
    80001262:	fffff097          	auipc	ra,0xfffff
    80001266:	31c080e7          	jalr	796(ra) # 8000057e <panic>
      printf("va=%p pte=%p\n", a, *pte);
    8000126a:	862a                	mv	a2,a0
    8000126c:	85ca                	mv	a1,s2
    8000126e:	00006517          	auipc	a0,0x6
    80001272:	f8a50513          	addi	a0,a0,-118 # 800071f8 <userret+0x168>
    80001276:	fffff097          	auipc	ra,0xfffff
    8000127a:	352080e7          	jalr	850(ra) # 800005c8 <printf>
      panic("uvmunmap: not mapped");
    8000127e:	00006517          	auipc	a0,0x6
    80001282:	f8a50513          	addi	a0,a0,-118 # 80007208 <userret+0x178>
    80001286:	fffff097          	auipc	ra,0xfffff
    8000128a:	2f8080e7          	jalr	760(ra) # 8000057e <panic>
      panic("uvmunmap: not a leaf");
    8000128e:	00006517          	auipc	a0,0x6
    80001292:	f9250513          	addi	a0,a0,-110 # 80007220 <userret+0x190>
    80001296:	fffff097          	auipc	ra,0xfffff
    8000129a:	2e8080e7          	jalr	744(ra) # 8000057e <panic>
      pa = PTE2PA(*pte);
    8000129e:	8129                	srli	a0,a0,0xa
      kfree((void*)pa);
    800012a0:	0532                	slli	a0,a0,0xc
    800012a2:	fffff097          	auipc	ra,0xfffff
    800012a6:	5f2080e7          	jalr	1522(ra) # 80000894 <kfree>
    *pte = 0;
    800012aa:	0004b023          	sd	zero,0(s1)
    if(a == last)
    800012ae:	03390763          	beq	s2,s3,800012dc <uvmunmap+0xb0>
    a += PGSIZE;
    800012b2:	995e                	add	s2,s2,s7
    if((pte = walk(pagetable, a, 0)) == 0)
    800012b4:	4601                	li	a2,0
    800012b6:	85ca                	mv	a1,s2
    800012b8:	8552                	mv	a0,s4
    800012ba:	00000097          	auipc	ra,0x0
    800012be:	bf8080e7          	jalr	-1032(ra) # 80000eb2 <walk>
    800012c2:	84aa                	mv	s1,a0
    800012c4:	d959                	beqz	a0,8000125a <uvmunmap+0x2e>
    if((*pte & PTE_V) == 0){
    800012c6:	6108                	ld	a0,0(a0)
    800012c8:	00157793          	andi	a5,a0,1
    800012cc:	dfd9                	beqz	a5,8000126a <uvmunmap+0x3e>
    if(PTE_FLAGS(*pte) == PTE_V)
    800012ce:	01f57793          	andi	a5,a0,31
    800012d2:	fb678ee3          	beq	a5,s6,8000128e <uvmunmap+0x62>
    if(do_free){
    800012d6:	fc0a8ae3          	beqz	s5,800012aa <uvmunmap+0x7e>
    800012da:	b7d1                	j	8000129e <uvmunmap+0x72>
}
    800012dc:	60a6                	ld	ra,72(sp)
    800012de:	6406                	ld	s0,64(sp)
    800012e0:	74e2                	ld	s1,56(sp)
    800012e2:	7942                	ld	s2,48(sp)
    800012e4:	79a2                	ld	s3,40(sp)
    800012e6:	7a02                	ld	s4,32(sp)
    800012e8:	6ae2                	ld	s5,24(sp)
    800012ea:	6b42                	ld	s6,16(sp)
    800012ec:	6ba2                	ld	s7,8(sp)
    800012ee:	6161                	addi	sp,sp,80
    800012f0:	8082                	ret

00000000800012f2 <uvmcreate>:
{
    800012f2:	1101                	addi	sp,sp,-32
    800012f4:	ec06                	sd	ra,24(sp)
    800012f6:	e822                	sd	s0,16(sp)
    800012f8:	e426                	sd	s1,8(sp)
    800012fa:	1000                	addi	s0,sp,32
  pagetable = (pagetable_t) kalloc();
    800012fc:	fffff097          	auipc	ra,0xfffff
    80001300:	696080e7          	jalr	1686(ra) # 80000992 <kalloc>
  if(pagetable == 0)
    80001304:	cd11                	beqz	a0,80001320 <uvmcreate+0x2e>
    80001306:	84aa                	mv	s1,a0
  memset(pagetable, 0, PGSIZE);
    80001308:	6605                	lui	a2,0x1
    8000130a:	4581                	li	a1,0
    8000130c:	00000097          	auipc	ra,0x0
    80001310:	8ba080e7          	jalr	-1862(ra) # 80000bc6 <memset>
}
    80001314:	8526                	mv	a0,s1
    80001316:	60e2                	ld	ra,24(sp)
    80001318:	6442                	ld	s0,16(sp)
    8000131a:	64a2                	ld	s1,8(sp)
    8000131c:	6105                	addi	sp,sp,32
    8000131e:	8082                	ret
    panic("uvmcreate: out of memory");
    80001320:	00006517          	auipc	a0,0x6
    80001324:	f1850513          	addi	a0,a0,-232 # 80007238 <userret+0x1a8>
    80001328:	fffff097          	auipc	ra,0xfffff
    8000132c:	256080e7          	jalr	598(ra) # 8000057e <panic>

0000000080001330 <uvminit>:
{
    80001330:	7179                	addi	sp,sp,-48
    80001332:	f406                	sd	ra,40(sp)
    80001334:	f022                	sd	s0,32(sp)
    80001336:	ec26                	sd	s1,24(sp)
    80001338:	e84a                	sd	s2,16(sp)
    8000133a:	e44e                	sd	s3,8(sp)
    8000133c:	e052                	sd	s4,0(sp)
    8000133e:	1800                	addi	s0,sp,48
  if(sz >= PGSIZE)
    80001340:	6785                	lui	a5,0x1
    80001342:	04f67863          	bleu	a5,a2,80001392 <uvminit+0x62>
    80001346:	8a2a                	mv	s4,a0
    80001348:	89ae                	mv	s3,a1
    8000134a:	84b2                	mv	s1,a2
  mem = kalloc();
    8000134c:	fffff097          	auipc	ra,0xfffff
    80001350:	646080e7          	jalr	1606(ra) # 80000992 <kalloc>
    80001354:	892a                	mv	s2,a0
  memset(mem, 0, PGSIZE);
    80001356:	6605                	lui	a2,0x1
    80001358:	4581                	li	a1,0
    8000135a:	00000097          	auipc	ra,0x0
    8000135e:	86c080e7          	jalr	-1940(ra) # 80000bc6 <memset>
  mappages(pagetable, 0, PGSIZE, (uint64)mem, PTE_W|PTE_R|PTE_X|PTE_U);
    80001362:	4779                	li	a4,30
    80001364:	86ca                	mv	a3,s2
    80001366:	6605                	lui	a2,0x1
    80001368:	4581                	li	a1,0
    8000136a:	8552                	mv	a0,s4
    8000136c:	00000097          	auipc	ra,0x0
    80001370:	d14080e7          	jalr	-748(ra) # 80001080 <mappages>
  memmove(mem, src, sz);
    80001374:	8626                	mv	a2,s1
    80001376:	85ce                	mv	a1,s3
    80001378:	854a                	mv	a0,s2
    8000137a:	00000097          	auipc	ra,0x0
    8000137e:	8b8080e7          	jalr	-1864(ra) # 80000c32 <memmove>
}
    80001382:	70a2                	ld	ra,40(sp)
    80001384:	7402                	ld	s0,32(sp)
    80001386:	64e2                	ld	s1,24(sp)
    80001388:	6942                	ld	s2,16(sp)
    8000138a:	69a2                	ld	s3,8(sp)
    8000138c:	6a02                	ld	s4,0(sp)
    8000138e:	6145                	addi	sp,sp,48
    80001390:	8082                	ret
    panic("inituvm: more than a page");
    80001392:	00006517          	auipc	a0,0x6
    80001396:	ec650513          	addi	a0,a0,-314 # 80007258 <userret+0x1c8>
    8000139a:	fffff097          	auipc	ra,0xfffff
    8000139e:	1e4080e7          	jalr	484(ra) # 8000057e <panic>

00000000800013a2 <uvmdealloc>:
  if(newsz >= oldsz)
    800013a2:	00b66463          	bltu	a2,a1,800013aa <uvmdealloc+0x8>
}
    800013a6:	852e                	mv	a0,a1
    800013a8:	8082                	ret
{
    800013aa:	1101                	addi	sp,sp,-32
    800013ac:	ec06                	sd	ra,24(sp)
    800013ae:	e822                	sd	s0,16(sp)
    800013b0:	e426                	sd	s1,8(sp)
    800013b2:	1000                	addi	s0,sp,32
    800013b4:	84b2                	mv	s1,a2
  uvmunmap(pagetable, newsz, oldsz - newsz, 1);
    800013b6:	4685                	li	a3,1
    800013b8:	40c58633          	sub	a2,a1,a2
    800013bc:	85a6                	mv	a1,s1
    800013be:	00000097          	auipc	ra,0x0
    800013c2:	e6e080e7          	jalr	-402(ra) # 8000122c <uvmunmap>
}
    800013c6:	8526                	mv	a0,s1
    800013c8:	60e2                	ld	ra,24(sp)
    800013ca:	6442                	ld	s0,16(sp)
    800013cc:	64a2                	ld	s1,8(sp)
    800013ce:	6105                	addi	sp,sp,32
    800013d0:	8082                	ret

00000000800013d2 <uvmalloc>:
  if(newsz < oldsz)
    800013d2:	0ab66163          	bltu	a2,a1,80001474 <uvmalloc+0xa2>
{
    800013d6:	7139                	addi	sp,sp,-64
    800013d8:	fc06                	sd	ra,56(sp)
    800013da:	f822                	sd	s0,48(sp)
    800013dc:	f426                	sd	s1,40(sp)
    800013de:	f04a                	sd	s2,32(sp)
    800013e0:	ec4e                	sd	s3,24(sp)
    800013e2:	e852                	sd	s4,16(sp)
    800013e4:	e456                	sd	s5,8(sp)
    800013e6:	0080                	addi	s0,sp,64
  oldsz = PGROUNDUP(oldsz);
    800013e8:	6a05                	lui	s4,0x1
    800013ea:	1a7d                	addi	s4,s4,-1
    800013ec:	95d2                	add	a1,a1,s4
    800013ee:	7a7d                	lui	s4,0xfffff
    800013f0:	0145fa33          	and	s4,a1,s4
  for(; a < newsz; a += PGSIZE){
    800013f4:	08ca7263          	bleu	a2,s4,80001478 <uvmalloc+0xa6>
    800013f8:	89b2                	mv	s3,a2
    800013fa:	8aaa                	mv	s5,a0
  a = oldsz;
    800013fc:	8952                	mv	s2,s4
    mem = kalloc();
    800013fe:	fffff097          	auipc	ra,0xfffff
    80001402:	594080e7          	jalr	1428(ra) # 80000992 <kalloc>
    80001406:	84aa                	mv	s1,a0
    if(mem == 0){
    80001408:	c51d                	beqz	a0,80001436 <uvmalloc+0x64>
    memset(mem, 0, PGSIZE);
    8000140a:	6605                	lui	a2,0x1
    8000140c:	4581                	li	a1,0
    8000140e:	fffff097          	auipc	ra,0xfffff
    80001412:	7b8080e7          	jalr	1976(ra) # 80000bc6 <memset>
    if(mappages(pagetable, a, PGSIZE, (uint64)mem, PTE_W|PTE_X|PTE_R|PTE_U) != 0){
    80001416:	4779                	li	a4,30
    80001418:	86a6                	mv	a3,s1
    8000141a:	6605                	lui	a2,0x1
    8000141c:	85ca                	mv	a1,s2
    8000141e:	8556                	mv	a0,s5
    80001420:	00000097          	auipc	ra,0x0
    80001424:	c60080e7          	jalr	-928(ra) # 80001080 <mappages>
    80001428:	e905                	bnez	a0,80001458 <uvmalloc+0x86>
  for(; a < newsz; a += PGSIZE){
    8000142a:	6785                	lui	a5,0x1
    8000142c:	993e                	add	s2,s2,a5
    8000142e:	fd3968e3          	bltu	s2,s3,800013fe <uvmalloc+0x2c>
  return newsz;
    80001432:	854e                	mv	a0,s3
    80001434:	a809                	j	80001446 <uvmalloc+0x74>
      uvmdealloc(pagetable, a, oldsz);
    80001436:	8652                	mv	a2,s4
    80001438:	85ca                	mv	a1,s2
    8000143a:	8556                	mv	a0,s5
    8000143c:	00000097          	auipc	ra,0x0
    80001440:	f66080e7          	jalr	-154(ra) # 800013a2 <uvmdealloc>
      return 0;
    80001444:	4501                	li	a0,0
}
    80001446:	70e2                	ld	ra,56(sp)
    80001448:	7442                	ld	s0,48(sp)
    8000144a:	74a2                	ld	s1,40(sp)
    8000144c:	7902                	ld	s2,32(sp)
    8000144e:	69e2                	ld	s3,24(sp)
    80001450:	6a42                	ld	s4,16(sp)
    80001452:	6aa2                	ld	s5,8(sp)
    80001454:	6121                	addi	sp,sp,64
    80001456:	8082                	ret
      kfree(mem);
    80001458:	8526                	mv	a0,s1
    8000145a:	fffff097          	auipc	ra,0xfffff
    8000145e:	43a080e7          	jalr	1082(ra) # 80000894 <kfree>
      uvmdealloc(pagetable, a, oldsz);
    80001462:	8652                	mv	a2,s4
    80001464:	85ca                	mv	a1,s2
    80001466:	8556                	mv	a0,s5
    80001468:	00000097          	auipc	ra,0x0
    8000146c:	f3a080e7          	jalr	-198(ra) # 800013a2 <uvmdealloc>
      return 0;
    80001470:	4501                	li	a0,0
    80001472:	bfd1                	j	80001446 <uvmalloc+0x74>
    return oldsz;
    80001474:	852e                	mv	a0,a1
}
    80001476:	8082                	ret
  return newsz;
    80001478:	8532                	mv	a0,a2
    8000147a:	b7f1                	j	80001446 <uvmalloc+0x74>

000000008000147c <uvmfree>:

// Free user memory pages,
// then free page-table pages.
void
uvmfree(pagetable_t pagetable, uint64 sz)
{
    8000147c:	1101                	addi	sp,sp,-32
    8000147e:	ec06                	sd	ra,24(sp)
    80001480:	e822                	sd	s0,16(sp)
    80001482:	e426                	sd	s1,8(sp)
    80001484:	1000                	addi	s0,sp,32
    80001486:	84aa                	mv	s1,a0
  uvmunmap(pagetable, 0, sz, 1);
    80001488:	4685                	li	a3,1
    8000148a:	862e                	mv	a2,a1
    8000148c:	4581                	li	a1,0
    8000148e:	00000097          	auipc	ra,0x0
    80001492:	d9e080e7          	jalr	-610(ra) # 8000122c <uvmunmap>
  freewalk(pagetable);
    80001496:	8526                	mv	a0,s1
    80001498:	00000097          	auipc	ra,0x0
    8000149c:	ac0080e7          	jalr	-1344(ra) # 80000f58 <freewalk>
}
    800014a0:	60e2                	ld	ra,24(sp)
    800014a2:	6442                	ld	s0,16(sp)
    800014a4:	64a2                	ld	s1,8(sp)
    800014a6:	6105                	addi	sp,sp,32
    800014a8:	8082                	ret

00000000800014aa <uvmcopy>:
  pte_t *pte;
  uint64 pa, i;
  uint flags;
  char *mem;

  for(i = 0; i < sz; i += PGSIZE){
    800014aa:	c671                	beqz	a2,80001576 <uvmcopy+0xcc>
{
    800014ac:	715d                	addi	sp,sp,-80
    800014ae:	e486                	sd	ra,72(sp)
    800014b0:	e0a2                	sd	s0,64(sp)
    800014b2:	fc26                	sd	s1,56(sp)
    800014b4:	f84a                	sd	s2,48(sp)
    800014b6:	f44e                	sd	s3,40(sp)
    800014b8:	f052                	sd	s4,32(sp)
    800014ba:	ec56                	sd	s5,24(sp)
    800014bc:	e85a                	sd	s6,16(sp)
    800014be:	e45e                	sd	s7,8(sp)
    800014c0:	0880                	addi	s0,sp,80
    800014c2:	8ab2                	mv	s5,a2
    800014c4:	8b2e                	mv	s6,a1
    800014c6:	8baa                	mv	s7,a0
  for(i = 0; i < sz; i += PGSIZE){
    800014c8:	4901                	li	s2,0
    if((pte = walk(old, i, 0)) == 0)
    800014ca:	4601                	li	a2,0
    800014cc:	85ca                	mv	a1,s2
    800014ce:	855e                	mv	a0,s7
    800014d0:	00000097          	auipc	ra,0x0
    800014d4:	9e2080e7          	jalr	-1566(ra) # 80000eb2 <walk>
    800014d8:	c531                	beqz	a0,80001524 <uvmcopy+0x7a>
      panic("copyuvm: pte should exist");
    if((*pte & PTE_V) == 0)
    800014da:	6118                	ld	a4,0(a0)
    800014dc:	00177793          	andi	a5,a4,1
    800014e0:	cbb1                	beqz	a5,80001534 <uvmcopy+0x8a>
      panic("copyuvm: page not present");
    pa = PTE2PA(*pte);
    800014e2:	00a75593          	srli	a1,a4,0xa
    800014e6:	00c59993          	slli	s3,a1,0xc
    flags = PTE_FLAGS(*pte);
    800014ea:	01f77493          	andi	s1,a4,31
    if((mem = kalloc()) == 0)
    800014ee:	fffff097          	auipc	ra,0xfffff
    800014f2:	4a4080e7          	jalr	1188(ra) # 80000992 <kalloc>
    800014f6:	8a2a                	mv	s4,a0
    800014f8:	c939                	beqz	a0,8000154e <uvmcopy+0xa4>
      goto err;
    memmove(mem, (char*)pa, PGSIZE);
    800014fa:	6605                	lui	a2,0x1
    800014fc:	85ce                	mv	a1,s3
    800014fe:	fffff097          	auipc	ra,0xfffff
    80001502:	734080e7          	jalr	1844(ra) # 80000c32 <memmove>
    if(mappages(new, i, PGSIZE, (uint64)mem, flags) != 0){
    80001506:	8726                	mv	a4,s1
    80001508:	86d2                	mv	a3,s4
    8000150a:	6605                	lui	a2,0x1
    8000150c:	85ca                	mv	a1,s2
    8000150e:	855a                	mv	a0,s6
    80001510:	00000097          	auipc	ra,0x0
    80001514:	b70080e7          	jalr	-1168(ra) # 80001080 <mappages>
    80001518:	e515                	bnez	a0,80001544 <uvmcopy+0x9a>
  for(i = 0; i < sz; i += PGSIZE){
    8000151a:	6785                	lui	a5,0x1
    8000151c:	993e                	add	s2,s2,a5
    8000151e:	fb5966e3          	bltu	s2,s5,800014ca <uvmcopy+0x20>
    80001522:	a83d                	j	80001560 <uvmcopy+0xb6>
      panic("copyuvm: pte should exist");
    80001524:	00006517          	auipc	a0,0x6
    80001528:	d5450513          	addi	a0,a0,-684 # 80007278 <userret+0x1e8>
    8000152c:	fffff097          	auipc	ra,0xfffff
    80001530:	052080e7          	jalr	82(ra) # 8000057e <panic>
      panic("copyuvm: page not present");
    80001534:	00006517          	auipc	a0,0x6
    80001538:	d6450513          	addi	a0,a0,-668 # 80007298 <userret+0x208>
    8000153c:	fffff097          	auipc	ra,0xfffff
    80001540:	042080e7          	jalr	66(ra) # 8000057e <panic>
      kfree(mem);
    80001544:	8552                	mv	a0,s4
    80001546:	fffff097          	auipc	ra,0xfffff
    8000154a:	34e080e7          	jalr	846(ra) # 80000894 <kfree>
    }
  }
  return 0;

 err:
  uvmunmap(new, 0, i, 1);
    8000154e:	4685                	li	a3,1
    80001550:	864a                	mv	a2,s2
    80001552:	4581                	li	a1,0
    80001554:	855a                	mv	a0,s6
    80001556:	00000097          	auipc	ra,0x0
    8000155a:	cd6080e7          	jalr	-810(ra) # 8000122c <uvmunmap>
  return -1;
    8000155e:	557d                	li	a0,-1
}
    80001560:	60a6                	ld	ra,72(sp)
    80001562:	6406                	ld	s0,64(sp)
    80001564:	74e2                	ld	s1,56(sp)
    80001566:	7942                	ld	s2,48(sp)
    80001568:	79a2                	ld	s3,40(sp)
    8000156a:	7a02                	ld	s4,32(sp)
    8000156c:	6ae2                	ld	s5,24(sp)
    8000156e:	6b42                	ld	s6,16(sp)
    80001570:	6ba2                	ld	s7,8(sp)
    80001572:	6161                	addi	sp,sp,80
    80001574:	8082                	ret
  return 0;
    80001576:	4501                	li	a0,0
}
    80001578:	8082                	ret

000000008000157a <uvmclear>:

// mark a PTE invalid for user access.
// used by exec for the user stack guard page.
void
uvmclear(pagetable_t pagetable, uint64 va)
{
    8000157a:	1141                	addi	sp,sp,-16
    8000157c:	e406                	sd	ra,8(sp)
    8000157e:	e022                	sd	s0,0(sp)
    80001580:	0800                	addi	s0,sp,16
  pte_t *pte;
  
  pte = walk(pagetable, va, 0);
    80001582:	4601                	li	a2,0
    80001584:	00000097          	auipc	ra,0x0
    80001588:	92e080e7          	jalr	-1746(ra) # 80000eb2 <walk>
  if(pte == 0)
    8000158c:	c901                	beqz	a0,8000159c <uvmclear+0x22>
    panic("uvmclear");
  *pte &= ~PTE_U;
    8000158e:	611c                	ld	a5,0(a0)
    80001590:	9bbd                	andi	a5,a5,-17
    80001592:	e11c                	sd	a5,0(a0)
}
    80001594:	60a2                	ld	ra,8(sp)
    80001596:	6402                	ld	s0,0(sp)
    80001598:	0141                	addi	sp,sp,16
    8000159a:	8082                	ret
    panic("uvmclear");
    8000159c:	00006517          	auipc	a0,0x6
    800015a0:	d1c50513          	addi	a0,a0,-740 # 800072b8 <userret+0x228>
    800015a4:	fffff097          	auipc	ra,0xfffff
    800015a8:	fda080e7          	jalr	-38(ra) # 8000057e <panic>

00000000800015ac <copyout>:
int
copyout(pagetable_t pagetable, uint64 dstva, char *src, uint64 len)
{
  uint64 n, va0, pa0;

  while(len > 0){
    800015ac:	cab5                	beqz	a3,80001620 <copyout+0x74>
{
    800015ae:	715d                	addi	sp,sp,-80
    800015b0:	e486                	sd	ra,72(sp)
    800015b2:	e0a2                	sd	s0,64(sp)
    800015b4:	fc26                	sd	s1,56(sp)
    800015b6:	f84a                	sd	s2,48(sp)
    800015b8:	f44e                	sd	s3,40(sp)
    800015ba:	f052                	sd	s4,32(sp)
    800015bc:	ec56                	sd	s5,24(sp)
    800015be:	e85a                	sd	s6,16(sp)
    800015c0:	e45e                	sd	s7,8(sp)
    800015c2:	e062                	sd	s8,0(sp)
    800015c4:	0880                	addi	s0,sp,80
    800015c6:	8c2a                	mv	s8,a0
    800015c8:	8a2e                	mv	s4,a1
    800015ca:	8ab2                	mv	s5,a2
    800015cc:	89b6                	mv	s3,a3
    va0 = (uint)PGROUNDDOWN(dstva);
    800015ce:	00100bb7          	lui	s7,0x100
    800015d2:	1bfd                	addi	s7,s7,-1
    800015d4:	0bb2                	slli	s7,s7,0xc
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == 0)
      return -1;
    n = PGSIZE - (dstva - va0);
    800015d6:	6b05                	lui	s6,0x1
    800015d8:	a015                	j	800015fc <copyout+0x50>
    if(n > len)
      n = len;
    memmove((void *)(pa0 + (dstva - va0)), src, n);
    800015da:	9552                	add	a0,a0,s4
    800015dc:	0004861b          	sext.w	a2,s1
    800015e0:	85d6                	mv	a1,s5
    800015e2:	41250533          	sub	a0,a0,s2
    800015e6:	fffff097          	auipc	ra,0xfffff
    800015ea:	64c080e7          	jalr	1612(ra) # 80000c32 <memmove>

    len -= n;
    800015ee:	409989b3          	sub	s3,s3,s1
    src += n;
    800015f2:	9aa6                	add	s5,s5,s1
    dstva = va0 + PGSIZE;
    800015f4:	01690a33          	add	s4,s2,s6
  while(len > 0){
    800015f8:	02098263          	beqz	s3,8000161c <copyout+0x70>
    va0 = (uint)PGROUNDDOWN(dstva);
    800015fc:	017a7933          	and	s2,s4,s7
    pa0 = walkaddr(pagetable, va0);
    80001600:	85ca                	mv	a1,s2
    80001602:	8562                	mv	a0,s8
    80001604:	00000097          	auipc	ra,0x0
    80001608:	9e4080e7          	jalr	-1564(ra) # 80000fe8 <walkaddr>
    if(pa0 == 0)
    8000160c:	cd01                	beqz	a0,80001624 <copyout+0x78>
    n = PGSIZE - (dstva - va0);
    8000160e:	414904b3          	sub	s1,s2,s4
    80001612:	94da                	add	s1,s1,s6
    if(n > len)
    80001614:	fc99f3e3          	bleu	s1,s3,800015da <copyout+0x2e>
    80001618:	84ce                	mv	s1,s3
    8000161a:	b7c1                	j	800015da <copyout+0x2e>
  }
  return 0;
    8000161c:	4501                	li	a0,0
    8000161e:	a021                	j	80001626 <copyout+0x7a>
    80001620:	4501                	li	a0,0
}
    80001622:	8082                	ret
      return -1;
    80001624:	557d                	li	a0,-1
}
    80001626:	60a6                	ld	ra,72(sp)
    80001628:	6406                	ld	s0,64(sp)
    8000162a:	74e2                	ld	s1,56(sp)
    8000162c:	7942                	ld	s2,48(sp)
    8000162e:	79a2                	ld	s3,40(sp)
    80001630:	7a02                	ld	s4,32(sp)
    80001632:	6ae2                	ld	s5,24(sp)
    80001634:	6b42                	ld	s6,16(sp)
    80001636:	6ba2                	ld	s7,8(sp)
    80001638:	6c02                	ld	s8,0(sp)
    8000163a:	6161                	addi	sp,sp,80
    8000163c:	8082                	ret

000000008000163e <copyin>:
int
copyin(pagetable_t pagetable, char *dst, uint64 srcva, uint64 len)
{
  uint64 n, va0, pa0;

  while(len > 0){
    8000163e:	cabd                	beqz	a3,800016b4 <copyin+0x76>
{
    80001640:	715d                	addi	sp,sp,-80
    80001642:	e486                	sd	ra,72(sp)
    80001644:	e0a2                	sd	s0,64(sp)
    80001646:	fc26                	sd	s1,56(sp)
    80001648:	f84a                	sd	s2,48(sp)
    8000164a:	f44e                	sd	s3,40(sp)
    8000164c:	f052                	sd	s4,32(sp)
    8000164e:	ec56                	sd	s5,24(sp)
    80001650:	e85a                	sd	s6,16(sp)
    80001652:	e45e                	sd	s7,8(sp)
    80001654:	e062                	sd	s8,0(sp)
    80001656:	0880                	addi	s0,sp,80
    80001658:	8c2a                	mv	s8,a0
    8000165a:	8aae                	mv	s5,a1
    8000165c:	8a32                	mv	s4,a2
    8000165e:	89b6                	mv	s3,a3
    va0 = (uint)PGROUNDDOWN(srcva);
    80001660:	00100bb7          	lui	s7,0x100
    80001664:	1bfd                	addi	s7,s7,-1
    80001666:	0bb2                	slli	s7,s7,0xc
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == 0)
      return -1;
    n = PGSIZE - (srcva - va0);
    80001668:	6b05                	lui	s6,0x1
    8000166a:	a01d                	j	80001690 <copyin+0x52>
    if(n > len)
      n = len;
    memmove(dst, (void *)(pa0 + (srcva - va0)), n);
    8000166c:	014505b3          	add	a1,a0,s4
    80001670:	0004861b          	sext.w	a2,s1
    80001674:	412585b3          	sub	a1,a1,s2
    80001678:	8556                	mv	a0,s5
    8000167a:	fffff097          	auipc	ra,0xfffff
    8000167e:	5b8080e7          	jalr	1464(ra) # 80000c32 <memmove>

    len -= n;
    80001682:	409989b3          	sub	s3,s3,s1
    dst += n;
    80001686:	9aa6                	add	s5,s5,s1
    srcva = va0 + PGSIZE;
    80001688:	01690a33          	add	s4,s2,s6
  while(len > 0){
    8000168c:	02098263          	beqz	s3,800016b0 <copyin+0x72>
    va0 = (uint)PGROUNDDOWN(srcva);
    80001690:	017a7933          	and	s2,s4,s7
    pa0 = walkaddr(pagetable, va0);
    80001694:	85ca                	mv	a1,s2
    80001696:	8562                	mv	a0,s8
    80001698:	00000097          	auipc	ra,0x0
    8000169c:	950080e7          	jalr	-1712(ra) # 80000fe8 <walkaddr>
    if(pa0 == 0)
    800016a0:	cd01                	beqz	a0,800016b8 <copyin+0x7a>
    n = PGSIZE - (srcva - va0);
    800016a2:	414904b3          	sub	s1,s2,s4
    800016a6:	94da                	add	s1,s1,s6
    if(n > len)
    800016a8:	fc99f2e3          	bleu	s1,s3,8000166c <copyin+0x2e>
    800016ac:	84ce                	mv	s1,s3
    800016ae:	bf7d                	j	8000166c <copyin+0x2e>
  }
  return 0;
    800016b0:	4501                	li	a0,0
    800016b2:	a021                	j	800016ba <copyin+0x7c>
    800016b4:	4501                	li	a0,0
}
    800016b6:	8082                	ret
      return -1;
    800016b8:	557d                	li	a0,-1
}
    800016ba:	60a6                	ld	ra,72(sp)
    800016bc:	6406                	ld	s0,64(sp)
    800016be:	74e2                	ld	s1,56(sp)
    800016c0:	7942                	ld	s2,48(sp)
    800016c2:	79a2                	ld	s3,40(sp)
    800016c4:	7a02                	ld	s4,32(sp)
    800016c6:	6ae2                	ld	s5,24(sp)
    800016c8:	6b42                	ld	s6,16(sp)
    800016ca:	6ba2                	ld	s7,8(sp)
    800016cc:	6c02                	ld	s8,0(sp)
    800016ce:	6161                	addi	sp,sp,80
    800016d0:	8082                	ret

00000000800016d2 <copyinstr>:
copyinstr(pagetable_t pagetable, char *dst, uint64 srcva, uint64 max)
{
  uint64 n, va0, pa0;
  int got_null = 0;

  while(got_null == 0 && max > 0){
    800016d2:	c2e9                	beqz	a3,80001794 <copyinstr+0xc2>
{
    800016d4:	715d                	addi	sp,sp,-80
    800016d6:	e486                	sd	ra,72(sp)
    800016d8:	e0a2                	sd	s0,64(sp)
    800016da:	fc26                	sd	s1,56(sp)
    800016dc:	f84a                	sd	s2,48(sp)
    800016de:	f44e                	sd	s3,40(sp)
    800016e0:	f052                	sd	s4,32(sp)
    800016e2:	ec56                	sd	s5,24(sp)
    800016e4:	e85a                	sd	s6,16(sp)
    800016e6:	e45e                	sd	s7,8(sp)
    800016e8:	e062                	sd	s8,0(sp)
    800016ea:	0880                	addi	s0,sp,80
    800016ec:	8aaa                	mv	s5,a0
    800016ee:	84ae                	mv	s1,a1
    800016f0:	8c32                	mv	s8,a2
    800016f2:	8bb6                	mv	s7,a3
    va0 = (uint)PGROUNDDOWN(srcva);
    800016f4:	00100a37          	lui	s4,0x100
    800016f8:	1a7d                	addi	s4,s4,-1
    800016fa:	0a32                	slli	s4,s4,0xc
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == 0)
      return -1;
    n = PGSIZE - (srcva - va0);
    800016fc:	6985                	lui	s3,0x1
    800016fe:	4b05                	li	s6,1
    80001700:	a801                	j	80001710 <copyinstr+0x3e>
    if(n > max)
      n = max;

    char *p = (char *) (pa0 + (srcva - va0));
    while(n > 0){
      if(*p == '\0'){
    80001702:	87a6                	mv	a5,s1
    80001704:	a085                	j	80001764 <copyinstr+0x92>
        *dst = *p;
      }
      --n;
      --max;
      p++;
      dst++;
    80001706:	84b2                	mv	s1,a2
    }

    srcva = va0 + PGSIZE;
    80001708:	01390c33          	add	s8,s2,s3
  while(got_null == 0 && max > 0){
    8000170c:	080b8063          	beqz	s7,8000178c <copyinstr+0xba>
    va0 = (uint)PGROUNDDOWN(srcva);
    80001710:	014c7933          	and	s2,s8,s4
    pa0 = walkaddr(pagetable, va0);
    80001714:	85ca                	mv	a1,s2
    80001716:	8556                	mv	a0,s5
    80001718:	00000097          	auipc	ra,0x0
    8000171c:	8d0080e7          	jalr	-1840(ra) # 80000fe8 <walkaddr>
    if(pa0 == 0)
    80001720:	c925                	beqz	a0,80001790 <copyinstr+0xbe>
    n = PGSIZE - (srcva - va0);
    80001722:	41890633          	sub	a2,s2,s8
    80001726:	964e                	add	a2,a2,s3
    if(n > max)
    80001728:	00cbf363          	bleu	a2,s7,8000172e <copyinstr+0x5c>
    8000172c:	865e                	mv	a2,s7
    char *p = (char *) (pa0 + (srcva - va0));
    8000172e:	9562                	add	a0,a0,s8
    80001730:	41250533          	sub	a0,a0,s2
    while(n > 0){
    80001734:	da71                	beqz	a2,80001708 <copyinstr+0x36>
      if(*p == '\0'){
    80001736:	00054703          	lbu	a4,0(a0)
    8000173a:	d761                	beqz	a4,80001702 <copyinstr+0x30>
    8000173c:	9626                	add	a2,a2,s1
    8000173e:	87a6                	mv	a5,s1
    80001740:	1bfd                	addi	s7,s7,-1
    80001742:	009b86b3          	add	a3,s7,s1
    80001746:	409b04b3          	sub	s1,s6,s1
    8000174a:	94aa                	add	s1,s1,a0
        *dst = *p;
    8000174c:	00e78023          	sb	a4,0(a5) # 1000 <_entry-0x7ffff000>
      --max;
    80001750:	40f68bb3          	sub	s7,a3,a5
      p++;
    80001754:	00f48733          	add	a4,s1,a5
      dst++;
    80001758:	0785                	addi	a5,a5,1
    while(n > 0){
    8000175a:	faf606e3          	beq	a2,a5,80001706 <copyinstr+0x34>
      if(*p == '\0'){
    8000175e:	00074703          	lbu	a4,0(a4)
    80001762:	f76d                	bnez	a4,8000174c <copyinstr+0x7a>
        *dst = '\0';
    80001764:	00078023          	sb	zero,0(a5)
    80001768:	4785                	li	a5,1
  }
  if(got_null){
    8000176a:	0017b513          	seqz	a0,a5
    8000176e:	40a0053b          	negw	a0,a0
    80001772:	2501                	sext.w	a0,a0
    return 0;
  } else {
    return -1;
  }
}
    80001774:	60a6                	ld	ra,72(sp)
    80001776:	6406                	ld	s0,64(sp)
    80001778:	74e2                	ld	s1,56(sp)
    8000177a:	7942                	ld	s2,48(sp)
    8000177c:	79a2                	ld	s3,40(sp)
    8000177e:	7a02                	ld	s4,32(sp)
    80001780:	6ae2                	ld	s5,24(sp)
    80001782:	6b42                	ld	s6,16(sp)
    80001784:	6ba2                	ld	s7,8(sp)
    80001786:	6c02                	ld	s8,0(sp)
    80001788:	6161                	addi	sp,sp,80
    8000178a:	8082                	ret
    8000178c:	4781                	li	a5,0
    8000178e:	bff1                	j	8000176a <copyinstr+0x98>
      return -1;
    80001790:	557d                	li	a0,-1
    80001792:	b7cd                	j	80001774 <copyinstr+0xa2>
  int got_null = 0;
    80001794:	4781                	li	a5,0
  if(got_null){
    80001796:	0017b513          	seqz	a0,a5
    8000179a:	40a0053b          	negw	a0,a0
    8000179e:	2501                	sext.w	a0,a0
}
    800017a0:	8082                	ret

00000000800017a2 <procinit>:

extern char trampoline[]; // trampoline.S

void
procinit(void)
{
    800017a2:	715d                	addi	sp,sp,-80
    800017a4:	e486                	sd	ra,72(sp)
    800017a6:	e0a2                	sd	s0,64(sp)
    800017a8:	fc26                	sd	s1,56(sp)
    800017aa:	f84a                	sd	s2,48(sp)
    800017ac:	f44e                	sd	s3,40(sp)
    800017ae:	f052                	sd	s4,32(sp)
    800017b0:	ec56                	sd	s5,24(sp)
    800017b2:	e85a                	sd	s6,16(sp)
    800017b4:	e45e                	sd	s7,8(sp)
    800017b6:	0880                	addi	s0,sp,80
  struct proc *p;
  
  initlock(&pid_lock, "nextpid");
    800017b8:	00006597          	auipc	a1,0x6
    800017bc:	b1058593          	addi	a1,a1,-1264 # 800072c8 <userret+0x238>
    800017c0:	00010517          	auipc	a0,0x10
    800017c4:	12850513          	addi	a0,a0,296 # 800118e8 <pid_lock>
    800017c8:	fffff097          	auipc	ra,0xfffff
    800017cc:	22a080e7          	jalr	554(ra) # 800009f2 <initlock>
  for(p = proc; p < &proc[NPROC]; p++) {
    800017d0:	00010917          	auipc	s2,0x10
    800017d4:	53090913          	addi	s2,s2,1328 # 80011d00 <proc>
      initlock(&p->lock, "proc");
    800017d8:	00006b97          	auipc	s7,0x6
    800017dc:	af8b8b93          	addi	s7,s7,-1288 # 800072d0 <userret+0x240>
      // Map it high in memory, followed by an invalid
      // guard page.
      char *pa = kalloc();
      if(pa == 0)
        panic("kalloc");
      uint64 va = KSTACK((int) (p - proc));
    800017e0:	8b4a                	mv	s6,s2
    800017e2:	00006a97          	auipc	s5,0x6
    800017e6:	21ea8a93          	addi	s5,s5,542 # 80007a00 <syscalls+0xd8>
    800017ea:	040009b7          	lui	s3,0x4000
    800017ee:	19fd                	addi	s3,s3,-1
    800017f0:	09b2                	slli	s3,s3,0xc
  for(p = proc; p < &proc[NPROC]; p++) {
    800017f2:	00016a17          	auipc	s4,0x16
    800017f6:	d0ea0a13          	addi	s4,s4,-754 # 80017500 <tickslock>
      initlock(&p->lock, "proc");
    800017fa:	85de                	mv	a1,s7
    800017fc:	854a                	mv	a0,s2
    800017fe:	fffff097          	auipc	ra,0xfffff
    80001802:	1f4080e7          	jalr	500(ra) # 800009f2 <initlock>
      char *pa = kalloc();
    80001806:	fffff097          	auipc	ra,0xfffff
    8000180a:	18c080e7          	jalr	396(ra) # 80000992 <kalloc>
    8000180e:	85aa                	mv	a1,a0
      if(pa == 0)
    80001810:	c929                	beqz	a0,80001862 <procinit+0xc0>
      uint64 va = KSTACK((int) (p - proc));
    80001812:	416904b3          	sub	s1,s2,s6
    80001816:	8495                	srai	s1,s1,0x5
    80001818:	000ab783          	ld	a5,0(s5)
    8000181c:	02f484b3          	mul	s1,s1,a5
    80001820:	2485                	addiw	s1,s1,1
    80001822:	00d4949b          	slliw	s1,s1,0xd
    80001826:	409984b3          	sub	s1,s3,s1
      kvmmap(va, (uint64)pa, PGSIZE, PTE_R | PTE_W);
    8000182a:	4699                	li	a3,6
    8000182c:	6605                	lui	a2,0x1
    8000182e:	8526                	mv	a0,s1
    80001830:	00000097          	auipc	ra,0x0
    80001834:	8dc080e7          	jalr	-1828(ra) # 8000110c <kvmmap>
      p->kstack = va;
    80001838:	02993c23          	sd	s1,56(s2)
  for(p = proc; p < &proc[NPROC]; p++) {
    8000183c:	16090913          	addi	s2,s2,352
    80001840:	fb491de3          	bne	s2,s4,800017fa <procinit+0x58>
  }
  kvminithart();
    80001844:	fffff097          	auipc	ra,0xfffff
    80001848:	77e080e7          	jalr	1918(ra) # 80000fc2 <kvminithart>
}
    8000184c:	60a6                	ld	ra,72(sp)
    8000184e:	6406                	ld	s0,64(sp)
    80001850:	74e2                	ld	s1,56(sp)
    80001852:	7942                	ld	s2,48(sp)
    80001854:	79a2                	ld	s3,40(sp)
    80001856:	7a02                	ld	s4,32(sp)
    80001858:	6ae2                	ld	s5,24(sp)
    8000185a:	6b42                	ld	s6,16(sp)
    8000185c:	6ba2                	ld	s7,8(sp)
    8000185e:	6161                	addi	sp,sp,80
    80001860:	8082                	ret
        panic("kalloc");
    80001862:	00006517          	auipc	a0,0x6
    80001866:	a7650513          	addi	a0,a0,-1418 # 800072d8 <userret+0x248>
    8000186a:	fffff097          	auipc	ra,0xfffff
    8000186e:	d14080e7          	jalr	-748(ra) # 8000057e <panic>

0000000080001872 <cpuid>:
// Must be called with interrupts disabled,
// to prevent race with process being moved
// to a different CPU.
int
cpuid()
{
    80001872:	1141                	addi	sp,sp,-16
    80001874:	e422                	sd	s0,8(sp)
    80001876:	0800                	addi	s0,sp,16
  asm volatile("mv %0, tp" : "=r" (x) );
    80001878:	8512                	mv	a0,tp
  int id = r_tp();
  return id;
}
    8000187a:	2501                	sext.w	a0,a0
    8000187c:	6422                	ld	s0,8(sp)
    8000187e:	0141                	addi	sp,sp,16
    80001880:	8082                	ret

0000000080001882 <mycpu>:

// Return this CPU's cpu struct.
// Interrupts must be disabled.
struct cpu*
mycpu(void) {
    80001882:	1141                	addi	sp,sp,-16
    80001884:	e422                	sd	s0,8(sp)
    80001886:	0800                	addi	s0,sp,16
    80001888:	8792                	mv	a5,tp
  int id = cpuid();
  struct cpu *c = &cpus[id];
    8000188a:	2781                	sext.w	a5,a5
    8000188c:	079e                	slli	a5,a5,0x7
  return c;
}
    8000188e:	00010517          	auipc	a0,0x10
    80001892:	07250513          	addi	a0,a0,114 # 80011900 <cpus>
    80001896:	953e                	add	a0,a0,a5
    80001898:	6422                	ld	s0,8(sp)
    8000189a:	0141                	addi	sp,sp,16
    8000189c:	8082                	ret

000000008000189e <myproc>:

// Return the current struct proc *, or zero if none.
struct proc*
myproc(void) {
    8000189e:	1101                	addi	sp,sp,-32
    800018a0:	ec06                	sd	ra,24(sp)
    800018a2:	e822                	sd	s0,16(sp)
    800018a4:	e426                	sd	s1,8(sp)
    800018a6:	1000                	addi	s0,sp,32
  push_off();
    800018a8:	fffff097          	auipc	ra,0xfffff
    800018ac:	160080e7          	jalr	352(ra) # 80000a08 <push_off>
    800018b0:	8792                	mv	a5,tp
  struct cpu *c = mycpu();
  struct proc *p = c->proc;
    800018b2:	2781                	sext.w	a5,a5
    800018b4:	079e                	slli	a5,a5,0x7
    800018b6:	00010717          	auipc	a4,0x10
    800018ba:	03270713          	addi	a4,a4,50 # 800118e8 <pid_lock>
    800018be:	97ba                	add	a5,a5,a4
    800018c0:	6f84                	ld	s1,24(a5)
  pop_off();
    800018c2:	fffff097          	auipc	ra,0xfffff
    800018c6:	192080e7          	jalr	402(ra) # 80000a54 <pop_off>
  return p;
}
    800018ca:	8526                	mv	a0,s1
    800018cc:	60e2                	ld	ra,24(sp)
    800018ce:	6442                	ld	s0,16(sp)
    800018d0:	64a2                	ld	s1,8(sp)
    800018d2:	6105                	addi	sp,sp,32
    800018d4:	8082                	ret

00000000800018d6 <forkret>:

// A fork child's very first scheduling by scheduler()
// will swtch to forkret.
void
forkret(void)
{
    800018d6:	1141                	addi	sp,sp,-16
    800018d8:	e406                	sd	ra,8(sp)
    800018da:	e022                	sd	s0,0(sp)
    800018dc:	0800                	addi	s0,sp,16
  static int first = 1;

  // Still holding p->lock from scheduler.
  release(&myproc()->lock);
    800018de:	00000097          	auipc	ra,0x0
    800018e2:	fc0080e7          	jalr	-64(ra) # 8000189e <myproc>
    800018e6:	fffff097          	auipc	ra,0xfffff
    800018ea:	282080e7          	jalr	642(ra) # 80000b68 <release>

  if (first) {
    800018ee:	00006797          	auipc	a5,0x6
    800018f2:	76a78793          	addi	a5,a5,1898 # 80008058 <first.1739>
    800018f6:	439c                	lw	a5,0(a5)
    800018f8:	eb89                	bnez	a5,8000190a <forkret+0x34>
    // be run from main().
    first = 0;
    fsinit(minor(ROOTDEV));
  }

  usertrapret();
    800018fa:	00001097          	auipc	ra,0x1
    800018fe:	be0080e7          	jalr	-1056(ra) # 800024da <usertrapret>
}
    80001902:	60a2                	ld	ra,8(sp)
    80001904:	6402                	ld	s0,0(sp)
    80001906:	0141                	addi	sp,sp,16
    80001908:	8082                	ret
    first = 0;
    8000190a:	00006797          	auipc	a5,0x6
    8000190e:	7407a723          	sw	zero,1870(a5) # 80008058 <first.1739>
    fsinit(minor(ROOTDEV));
    80001912:	4501                	li	a0,0
    80001914:	00002097          	auipc	ra,0x2
    80001918:	942080e7          	jalr	-1726(ra) # 80003256 <fsinit>
    8000191c:	bff9                	j	800018fa <forkret+0x24>

000000008000191e <allocpid>:
allocpid() {
    8000191e:	1101                	addi	sp,sp,-32
    80001920:	ec06                	sd	ra,24(sp)
    80001922:	e822                	sd	s0,16(sp)
    80001924:	e426                	sd	s1,8(sp)
    80001926:	e04a                	sd	s2,0(sp)
    80001928:	1000                	addi	s0,sp,32
  acquire(&pid_lock);
    8000192a:	00010917          	auipc	s2,0x10
    8000192e:	fbe90913          	addi	s2,s2,-66 # 800118e8 <pid_lock>
    80001932:	854a                	mv	a0,s2
    80001934:	fffff097          	auipc	ra,0xfffff
    80001938:	1cc080e7          	jalr	460(ra) # 80000b00 <acquire>
  pid = nextpid;
    8000193c:	00006797          	auipc	a5,0x6
    80001940:	72078793          	addi	a5,a5,1824 # 8000805c <nextpid>
    80001944:	4384                	lw	s1,0(a5)
  nextpid = nextpid + 1;
    80001946:	0014871b          	addiw	a4,s1,1
    8000194a:	c398                	sw	a4,0(a5)
  release(&pid_lock);
    8000194c:	854a                	mv	a0,s2
    8000194e:	fffff097          	auipc	ra,0xfffff
    80001952:	21a080e7          	jalr	538(ra) # 80000b68 <release>
}
    80001956:	8526                	mv	a0,s1
    80001958:	60e2                	ld	ra,24(sp)
    8000195a:	6442                	ld	s0,16(sp)
    8000195c:	64a2                	ld	s1,8(sp)
    8000195e:	6902                	ld	s2,0(sp)
    80001960:	6105                	addi	sp,sp,32
    80001962:	8082                	ret

0000000080001964 <proc_pagetable>:
{
    80001964:	1101                	addi	sp,sp,-32
    80001966:	ec06                	sd	ra,24(sp)
    80001968:	e822                	sd	s0,16(sp)
    8000196a:	e426                	sd	s1,8(sp)
    8000196c:	e04a                	sd	s2,0(sp)
    8000196e:	1000                	addi	s0,sp,32
    80001970:	892a                	mv	s2,a0
  pagetable = uvmcreate();
    80001972:	00000097          	auipc	ra,0x0
    80001976:	980080e7          	jalr	-1664(ra) # 800012f2 <uvmcreate>
    8000197a:	84aa                	mv	s1,a0
  mappages(pagetable, TRAMPOLINE, PGSIZE,
    8000197c:	4729                	li	a4,10
    8000197e:	00005697          	auipc	a3,0x5
    80001982:	68268693          	addi	a3,a3,1666 # 80007000 <trampoline>
    80001986:	6605                	lui	a2,0x1
    80001988:	040005b7          	lui	a1,0x4000
    8000198c:	15fd                	addi	a1,a1,-1
    8000198e:	05b2                	slli	a1,a1,0xc
    80001990:	fffff097          	auipc	ra,0xfffff
    80001994:	6f0080e7          	jalr	1776(ra) # 80001080 <mappages>
  mappages(pagetable, TRAPFRAME, PGSIZE,
    80001998:	4719                	li	a4,6
    8000199a:	05093683          	ld	a3,80(s2)
    8000199e:	6605                	lui	a2,0x1
    800019a0:	020005b7          	lui	a1,0x2000
    800019a4:	15fd                	addi	a1,a1,-1
    800019a6:	05b6                	slli	a1,a1,0xd
    800019a8:	8526                	mv	a0,s1
    800019aa:	fffff097          	auipc	ra,0xfffff
    800019ae:	6d6080e7          	jalr	1750(ra) # 80001080 <mappages>
}
    800019b2:	8526                	mv	a0,s1
    800019b4:	60e2                	ld	ra,24(sp)
    800019b6:	6442                	ld	s0,16(sp)
    800019b8:	64a2                	ld	s1,8(sp)
    800019ba:	6902                	ld	s2,0(sp)
    800019bc:	6105                	addi	sp,sp,32
    800019be:	8082                	ret

00000000800019c0 <allocproc>:
{
    800019c0:	1101                	addi	sp,sp,-32
    800019c2:	ec06                	sd	ra,24(sp)
    800019c4:	e822                	sd	s0,16(sp)
    800019c6:	e426                	sd	s1,8(sp)
    800019c8:	e04a                	sd	s2,0(sp)
    800019ca:	1000                	addi	s0,sp,32
  for(p = proc; p < &proc[NPROC]; p++) {
    800019cc:	00010497          	auipc	s1,0x10
    800019d0:	33448493          	addi	s1,s1,820 # 80011d00 <proc>
    800019d4:	00016917          	auipc	s2,0x16
    800019d8:	b2c90913          	addi	s2,s2,-1236 # 80017500 <tickslock>
    acquire(&p->lock);
    800019dc:	8526                	mv	a0,s1
    800019de:	fffff097          	auipc	ra,0xfffff
    800019e2:	122080e7          	jalr	290(ra) # 80000b00 <acquire>
    if(p->state == UNUSED) {
    800019e6:	4c9c                	lw	a5,24(s1)
    800019e8:	cf81                	beqz	a5,80001a00 <allocproc+0x40>
      release(&p->lock);
    800019ea:	8526                	mv	a0,s1
    800019ec:	fffff097          	auipc	ra,0xfffff
    800019f0:	17c080e7          	jalr	380(ra) # 80000b68 <release>
  for(p = proc; p < &proc[NPROC]; p++) {
    800019f4:	16048493          	addi	s1,s1,352
    800019f8:	ff2492e3          	bne	s1,s2,800019dc <allocproc+0x1c>
  return 0;
    800019fc:	4481                	li	s1,0
    800019fe:	a0a9                	j	80001a48 <allocproc+0x88>
  p->pid = allocpid();
    80001a00:	00000097          	auipc	ra,0x0
    80001a04:	f1e080e7          	jalr	-226(ra) # 8000191e <allocpid>
    80001a08:	d8c8                	sw	a0,52(s1)
  if((p->tf = (struct trapframe *)kalloc()) == 0){
    80001a0a:	fffff097          	auipc	ra,0xfffff
    80001a0e:	f88080e7          	jalr	-120(ra) # 80000992 <kalloc>
    80001a12:	892a                	mv	s2,a0
    80001a14:	e8a8                	sd	a0,80(s1)
    80001a16:	c121                	beqz	a0,80001a56 <allocproc+0x96>
  p->pagetable = proc_pagetable(p);
    80001a18:	8526                	mv	a0,s1
    80001a1a:	00000097          	auipc	ra,0x0
    80001a1e:	f4a080e7          	jalr	-182(ra) # 80001964 <proc_pagetable>
    80001a22:	e4a8                	sd	a0,72(s1)
  memset(&p->context, 0, sizeof p->context);
    80001a24:	07000613          	li	a2,112
    80001a28:	4581                	li	a1,0
    80001a2a:	05848513          	addi	a0,s1,88
    80001a2e:	fffff097          	auipc	ra,0xfffff
    80001a32:	198080e7          	jalr	408(ra) # 80000bc6 <memset>
  p->context.ra = (uint64)forkret;
    80001a36:	00000797          	auipc	a5,0x0
    80001a3a:	ea078793          	addi	a5,a5,-352 # 800018d6 <forkret>
    80001a3e:	ecbc                	sd	a5,88(s1)
  p->context.sp = p->kstack + PGSIZE;
    80001a40:	7c9c                	ld	a5,56(s1)
    80001a42:	6705                	lui	a4,0x1
    80001a44:	97ba                	add	a5,a5,a4
    80001a46:	f0bc                	sd	a5,96(s1)
}
    80001a48:	8526                	mv	a0,s1
    80001a4a:	60e2                	ld	ra,24(sp)
    80001a4c:	6442                	ld	s0,16(sp)
    80001a4e:	64a2                	ld	s1,8(sp)
    80001a50:	6902                	ld	s2,0(sp)
    80001a52:	6105                	addi	sp,sp,32
    80001a54:	8082                	ret
    release(&p->lock);
    80001a56:	8526                	mv	a0,s1
    80001a58:	fffff097          	auipc	ra,0xfffff
    80001a5c:	110080e7          	jalr	272(ra) # 80000b68 <release>
    return 0;
    80001a60:	84ca                	mv	s1,s2
    80001a62:	b7dd                	j	80001a48 <allocproc+0x88>

0000000080001a64 <proc_freepagetable>:
{
    80001a64:	1101                	addi	sp,sp,-32
    80001a66:	ec06                	sd	ra,24(sp)
    80001a68:	e822                	sd	s0,16(sp)
    80001a6a:	e426                	sd	s1,8(sp)
    80001a6c:	e04a                	sd	s2,0(sp)
    80001a6e:	1000                	addi	s0,sp,32
    80001a70:	84aa                	mv	s1,a0
    80001a72:	892e                	mv	s2,a1
  uvmunmap(pagetable, TRAMPOLINE, PGSIZE, 0);
    80001a74:	4681                	li	a3,0
    80001a76:	6605                	lui	a2,0x1
    80001a78:	040005b7          	lui	a1,0x4000
    80001a7c:	15fd                	addi	a1,a1,-1
    80001a7e:	05b2                	slli	a1,a1,0xc
    80001a80:	fffff097          	auipc	ra,0xfffff
    80001a84:	7ac080e7          	jalr	1964(ra) # 8000122c <uvmunmap>
  uvmunmap(pagetable, TRAPFRAME, PGSIZE, 0);
    80001a88:	4681                	li	a3,0
    80001a8a:	6605                	lui	a2,0x1
    80001a8c:	020005b7          	lui	a1,0x2000
    80001a90:	15fd                	addi	a1,a1,-1
    80001a92:	05b6                	slli	a1,a1,0xd
    80001a94:	8526                	mv	a0,s1
    80001a96:	fffff097          	auipc	ra,0xfffff
    80001a9a:	796080e7          	jalr	1942(ra) # 8000122c <uvmunmap>
  if(sz > 0)
    80001a9e:	00091863          	bnez	s2,80001aae <proc_freepagetable+0x4a>
}
    80001aa2:	60e2                	ld	ra,24(sp)
    80001aa4:	6442                	ld	s0,16(sp)
    80001aa6:	64a2                	ld	s1,8(sp)
    80001aa8:	6902                	ld	s2,0(sp)
    80001aaa:	6105                	addi	sp,sp,32
    80001aac:	8082                	ret
    uvmfree(pagetable, sz);
    80001aae:	85ca                	mv	a1,s2
    80001ab0:	8526                	mv	a0,s1
    80001ab2:	00000097          	auipc	ra,0x0
    80001ab6:	9ca080e7          	jalr	-1590(ra) # 8000147c <uvmfree>
}
    80001aba:	b7e5                	j	80001aa2 <proc_freepagetable+0x3e>

0000000080001abc <freeproc>:
{
    80001abc:	1101                	addi	sp,sp,-32
    80001abe:	ec06                	sd	ra,24(sp)
    80001ac0:	e822                	sd	s0,16(sp)
    80001ac2:	e426                	sd	s1,8(sp)
    80001ac4:	1000                	addi	s0,sp,32
    80001ac6:	84aa                	mv	s1,a0
  if(p->tf)
    80001ac8:	6928                	ld	a0,80(a0)
    80001aca:	c509                	beqz	a0,80001ad4 <freeproc+0x18>
    kfree((void*)p->tf);
    80001acc:	fffff097          	auipc	ra,0xfffff
    80001ad0:	dc8080e7          	jalr	-568(ra) # 80000894 <kfree>
  p->tf = 0;
    80001ad4:	0404b823          	sd	zero,80(s1)
  if(p->pagetable)
    80001ad8:	64a8                	ld	a0,72(s1)
    80001ada:	c511                	beqz	a0,80001ae6 <freeproc+0x2a>
    proc_freepagetable(p->pagetable, p->sz);
    80001adc:	60ac                	ld	a1,64(s1)
    80001ade:	00000097          	auipc	ra,0x0
    80001ae2:	f86080e7          	jalr	-122(ra) # 80001a64 <proc_freepagetable>
  p->pagetable = 0;
    80001ae6:	0404b423          	sd	zero,72(s1)
  p->sz = 0;
    80001aea:	0404b023          	sd	zero,64(s1)
  p->pid = 0;
    80001aee:	0204aa23          	sw	zero,52(s1)
  p->parent = 0;
    80001af2:	0204b023          	sd	zero,32(s1)
  p->name[0] = 0;
    80001af6:	14048823          	sb	zero,336(s1)
  p->chan = 0;
    80001afa:	0204b423          	sd	zero,40(s1)
  p->killed = 0;
    80001afe:	0204a823          	sw	zero,48(s1)
  p->state = UNUSED;
    80001b02:	0004ac23          	sw	zero,24(s1)
}
    80001b06:	60e2                	ld	ra,24(sp)
    80001b08:	6442                	ld	s0,16(sp)
    80001b0a:	64a2                	ld	s1,8(sp)
    80001b0c:	6105                	addi	sp,sp,32
    80001b0e:	8082                	ret

0000000080001b10 <userinit>:
{
    80001b10:	1101                	addi	sp,sp,-32
    80001b12:	ec06                	sd	ra,24(sp)
    80001b14:	e822                	sd	s0,16(sp)
    80001b16:	e426                	sd	s1,8(sp)
    80001b18:	1000                	addi	s0,sp,32
  p = allocproc();
    80001b1a:	00000097          	auipc	ra,0x0
    80001b1e:	ea6080e7          	jalr	-346(ra) # 800019c0 <allocproc>
    80001b22:	84aa                	mv	s1,a0
  initproc = p;
    80001b24:	00027797          	auipc	a5,0x27
    80001b28:	4ea7be23          	sd	a0,1276(a5) # 80029020 <initproc>
  uvminit(p->pagetable, initcode, sizeof(initcode));
    80001b2c:	03300613          	li	a2,51
    80001b30:	00006597          	auipc	a1,0x6
    80001b34:	4d058593          	addi	a1,a1,1232 # 80008000 <initcode>
    80001b38:	6528                	ld	a0,72(a0)
    80001b3a:	fffff097          	auipc	ra,0xfffff
    80001b3e:	7f6080e7          	jalr	2038(ra) # 80001330 <uvminit>
  p->sz = PGSIZE;
    80001b42:	6785                	lui	a5,0x1
    80001b44:	e0bc                	sd	a5,64(s1)
  p->tf->epc = 0;      // user program counter
    80001b46:	68b8                	ld	a4,80(s1)
    80001b48:	00073c23          	sd	zero,24(a4) # 1018 <_entry-0x7fffefe8>
  p->tf->sp = PGSIZE;  // user stack pointer
    80001b4c:	68b8                	ld	a4,80(s1)
    80001b4e:	fb1c                	sd	a5,48(a4)
  safestrcpy(p->name, "initcode", sizeof(p->name));
    80001b50:	4641                	li	a2,16
    80001b52:	00005597          	auipc	a1,0x5
    80001b56:	78e58593          	addi	a1,a1,1934 # 800072e0 <userret+0x250>
    80001b5a:	15048513          	addi	a0,s1,336
    80001b5e:	fffff097          	auipc	ra,0xfffff
    80001b62:	1e0080e7          	jalr	480(ra) # 80000d3e <safestrcpy>
  p->cwd = namei("/");
    80001b66:	00005517          	auipc	a0,0x5
    80001b6a:	78a50513          	addi	a0,a0,1930 # 800072f0 <userret+0x260>
    80001b6e:	00002097          	auipc	ra,0x2
    80001b72:	0f8080e7          	jalr	248(ra) # 80003c66 <namei>
    80001b76:	14a4b423          	sd	a0,328(s1)
  p->state = RUNNABLE;
    80001b7a:	4789                	li	a5,2
    80001b7c:	cc9c                	sw	a5,24(s1)
  release(&p->lock);
    80001b7e:	8526                	mv	a0,s1
    80001b80:	fffff097          	auipc	ra,0xfffff
    80001b84:	fe8080e7          	jalr	-24(ra) # 80000b68 <release>
}
    80001b88:	60e2                	ld	ra,24(sp)
    80001b8a:	6442                	ld	s0,16(sp)
    80001b8c:	64a2                	ld	s1,8(sp)
    80001b8e:	6105                	addi	sp,sp,32
    80001b90:	8082                	ret

0000000080001b92 <growproc>:
{
    80001b92:	1101                	addi	sp,sp,-32
    80001b94:	ec06                	sd	ra,24(sp)
    80001b96:	e822                	sd	s0,16(sp)
    80001b98:	e426                	sd	s1,8(sp)
    80001b9a:	e04a                	sd	s2,0(sp)
    80001b9c:	1000                	addi	s0,sp,32
    80001b9e:	84aa                	mv	s1,a0
  struct proc *p = myproc();
    80001ba0:	00000097          	auipc	ra,0x0
    80001ba4:	cfe080e7          	jalr	-770(ra) # 8000189e <myproc>
    80001ba8:	892a                	mv	s2,a0
  sz = p->sz;
    80001baa:	612c                	ld	a1,64(a0)
    80001bac:	0005851b          	sext.w	a0,a1
  if(n > 0){
    80001bb0:	00904f63          	bgtz	s1,80001bce <growproc+0x3c>
  } else if(n < 0){
    80001bb4:	0204cd63          	bltz	s1,80001bee <growproc+0x5c>
  p->sz = sz;
    80001bb8:	1502                	slli	a0,a0,0x20
    80001bba:	9101                	srli	a0,a0,0x20
    80001bbc:	04a93023          	sd	a0,64(s2)
  return 0;
    80001bc0:	4501                	li	a0,0
}
    80001bc2:	60e2                	ld	ra,24(sp)
    80001bc4:	6442                	ld	s0,16(sp)
    80001bc6:	64a2                	ld	s1,8(sp)
    80001bc8:	6902                	ld	s2,0(sp)
    80001bca:	6105                	addi	sp,sp,32
    80001bcc:	8082                	ret
    if((sz = uvmalloc(p->pagetable, sz, sz + n)) == 0) {
    80001bce:	00a4863b          	addw	a2,s1,a0
    80001bd2:	1602                	slli	a2,a2,0x20
    80001bd4:	9201                	srli	a2,a2,0x20
    80001bd6:	1582                	slli	a1,a1,0x20
    80001bd8:	9181                	srli	a1,a1,0x20
    80001bda:	04893503          	ld	a0,72(s2)
    80001bde:	fffff097          	auipc	ra,0xfffff
    80001be2:	7f4080e7          	jalr	2036(ra) # 800013d2 <uvmalloc>
    80001be6:	2501                	sext.w	a0,a0
    80001be8:	f961                	bnez	a0,80001bb8 <growproc+0x26>
      return -1;
    80001bea:	557d                	li	a0,-1
    80001bec:	bfd9                	j	80001bc2 <growproc+0x30>
    if((sz = uvmdealloc(p->pagetable, sz, sz + n)) == 0) {
    80001bee:	00a4863b          	addw	a2,s1,a0
    80001bf2:	1602                	slli	a2,a2,0x20
    80001bf4:	9201                	srli	a2,a2,0x20
    80001bf6:	1582                	slli	a1,a1,0x20
    80001bf8:	9181                	srli	a1,a1,0x20
    80001bfa:	04893503          	ld	a0,72(s2)
    80001bfe:	fffff097          	auipc	ra,0xfffff
    80001c02:	7a4080e7          	jalr	1956(ra) # 800013a2 <uvmdealloc>
    80001c06:	2501                	sext.w	a0,a0
    80001c08:	f945                	bnez	a0,80001bb8 <growproc+0x26>
      return -1;
    80001c0a:	557d                	li	a0,-1
    80001c0c:	bf5d                	j	80001bc2 <growproc+0x30>

0000000080001c0e <fork>:
{
    80001c0e:	7179                	addi	sp,sp,-48
    80001c10:	f406                	sd	ra,40(sp)
    80001c12:	f022                	sd	s0,32(sp)
    80001c14:	ec26                	sd	s1,24(sp)
    80001c16:	e84a                	sd	s2,16(sp)
    80001c18:	e44e                	sd	s3,8(sp)
    80001c1a:	e052                	sd	s4,0(sp)
    80001c1c:	1800                	addi	s0,sp,48
  struct proc *p = myproc();
    80001c1e:	00000097          	auipc	ra,0x0
    80001c22:	c80080e7          	jalr	-896(ra) # 8000189e <myproc>
    80001c26:	892a                	mv	s2,a0
  if((np = allocproc()) == 0){
    80001c28:	00000097          	auipc	ra,0x0
    80001c2c:	d98080e7          	jalr	-616(ra) # 800019c0 <allocproc>
    80001c30:	c175                	beqz	a0,80001d14 <fork+0x106>
    80001c32:	89aa                	mv	s3,a0
  if(uvmcopy(p->pagetable, np->pagetable, p->sz) < 0){
    80001c34:	04093603          	ld	a2,64(s2)
    80001c38:	652c                	ld	a1,72(a0)
    80001c3a:	04893503          	ld	a0,72(s2)
    80001c3e:	00000097          	auipc	ra,0x0
    80001c42:	86c080e7          	jalr	-1940(ra) # 800014aa <uvmcopy>
    80001c46:	04054863          	bltz	a0,80001c96 <fork+0x88>
  np->sz = p->sz;
    80001c4a:	04093783          	ld	a5,64(s2)
    80001c4e:	04f9b023          	sd	a5,64(s3) # 4000040 <_entry-0x7bffffc0>
  np->parent = p;
    80001c52:	0329b023          	sd	s2,32(s3)
  *(np->tf) = *(p->tf);
    80001c56:	05093683          	ld	a3,80(s2)
    80001c5a:	87b6                	mv	a5,a3
    80001c5c:	0509b703          	ld	a4,80(s3)
    80001c60:	12068693          	addi	a3,a3,288
    80001c64:	0007b803          	ld	a6,0(a5) # 1000 <_entry-0x7ffff000>
    80001c68:	6788                	ld	a0,8(a5)
    80001c6a:	6b8c                	ld	a1,16(a5)
    80001c6c:	6f90                	ld	a2,24(a5)
    80001c6e:	01073023          	sd	a6,0(a4)
    80001c72:	e708                	sd	a0,8(a4)
    80001c74:	eb0c                	sd	a1,16(a4)
    80001c76:	ef10                	sd	a2,24(a4)
    80001c78:	02078793          	addi	a5,a5,32
    80001c7c:	02070713          	addi	a4,a4,32
    80001c80:	fed792e3          	bne	a5,a3,80001c64 <fork+0x56>
  np->tf->a0 = 0;
    80001c84:	0509b783          	ld	a5,80(s3)
    80001c88:	0607b823          	sd	zero,112(a5)
    80001c8c:	0c800493          	li	s1,200
  for(i = 0; i < NOFILE; i++)
    80001c90:	14800a13          	li	s4,328
    80001c94:	a03d                	j	80001cc2 <fork+0xb4>
    freeproc(np);
    80001c96:	854e                	mv	a0,s3
    80001c98:	00000097          	auipc	ra,0x0
    80001c9c:	e24080e7          	jalr	-476(ra) # 80001abc <freeproc>
    release(&np->lock);
    80001ca0:	854e                	mv	a0,s3
    80001ca2:	fffff097          	auipc	ra,0xfffff
    80001ca6:	ec6080e7          	jalr	-314(ra) # 80000b68 <release>
    return -1;
    80001caa:	54fd                	li	s1,-1
    80001cac:	a899                	j	80001d02 <fork+0xf4>
      np->ofile[i] = filedup(p->ofile[i]);
    80001cae:	00003097          	auipc	ra,0x3
    80001cb2:	8da080e7          	jalr	-1830(ra) # 80004588 <filedup>
    80001cb6:	009987b3          	add	a5,s3,s1
    80001cba:	e388                	sd	a0,0(a5)
  for(i = 0; i < NOFILE; i++)
    80001cbc:	04a1                	addi	s1,s1,8
    80001cbe:	01448763          	beq	s1,s4,80001ccc <fork+0xbe>
    if(p->ofile[i])
    80001cc2:	009907b3          	add	a5,s2,s1
    80001cc6:	6388                	ld	a0,0(a5)
    80001cc8:	f17d                	bnez	a0,80001cae <fork+0xa0>
    80001cca:	bfcd                	j	80001cbc <fork+0xae>
  np->cwd = idup(p->cwd);
    80001ccc:	14893503          	ld	a0,328(s2)
    80001cd0:	00001097          	auipc	ra,0x1
    80001cd4:	7c2080e7          	jalr	1986(ra) # 80003492 <idup>
    80001cd8:	14a9b423          	sd	a0,328(s3)
  safestrcpy(np->name, p->name, sizeof(p->name));
    80001cdc:	4641                	li	a2,16
    80001cde:	15090593          	addi	a1,s2,336
    80001ce2:	15098513          	addi	a0,s3,336
    80001ce6:	fffff097          	auipc	ra,0xfffff
    80001cea:	058080e7          	jalr	88(ra) # 80000d3e <safestrcpy>
  pid = np->pid;
    80001cee:	0349a483          	lw	s1,52(s3)
  np->state = RUNNABLE;
    80001cf2:	4789                	li	a5,2
    80001cf4:	00f9ac23          	sw	a5,24(s3)
  release(&np->lock);
    80001cf8:	854e                	mv	a0,s3
    80001cfa:	fffff097          	auipc	ra,0xfffff
    80001cfe:	e6e080e7          	jalr	-402(ra) # 80000b68 <release>
}
    80001d02:	8526                	mv	a0,s1
    80001d04:	70a2                	ld	ra,40(sp)
    80001d06:	7402                	ld	s0,32(sp)
    80001d08:	64e2                	ld	s1,24(sp)
    80001d0a:	6942                	ld	s2,16(sp)
    80001d0c:	69a2                	ld	s3,8(sp)
    80001d0e:	6a02                	ld	s4,0(sp)
    80001d10:	6145                	addi	sp,sp,48
    80001d12:	8082                	ret
    return -1;
    80001d14:	54fd                	li	s1,-1
    80001d16:	b7f5                	j	80001d02 <fork+0xf4>

0000000080001d18 <reparent>:
reparent(struct proc *p, struct proc *parent) {
    80001d18:	711d                	addi	sp,sp,-96
    80001d1a:	ec86                	sd	ra,88(sp)
    80001d1c:	e8a2                	sd	s0,80(sp)
    80001d1e:	e4a6                	sd	s1,72(sp)
    80001d20:	e0ca                	sd	s2,64(sp)
    80001d22:	fc4e                	sd	s3,56(sp)
    80001d24:	f852                	sd	s4,48(sp)
    80001d26:	f456                	sd	s5,40(sp)
    80001d28:	f05a                	sd	s6,32(sp)
    80001d2a:	ec5e                	sd	s7,24(sp)
    80001d2c:	e862                	sd	s8,16(sp)
    80001d2e:	e466                	sd	s9,8(sp)
    80001d30:	1080                	addi	s0,sp,96
    80001d32:	892a                	mv	s2,a0
  int child_of_init = (p->parent == initproc);
    80001d34:	02053b83          	ld	s7,32(a0)
    80001d38:	00027797          	auipc	a5,0x27
    80001d3c:	2e878793          	addi	a5,a5,744 # 80029020 <initproc>
    80001d40:	0007bb03          	ld	s6,0(a5)
  for(pp = proc; pp < &proc[NPROC]; pp++){
    80001d44:	00010497          	auipc	s1,0x10
    80001d48:	fbc48493          	addi	s1,s1,-68 # 80011d00 <proc>
      pp->parent = initproc;
    80001d4c:	8a3e                	mv	s4,a5
      if(pp->state == ZOMBIE) {
    80001d4e:	4a91                	li	s5,4
// Wake up p if it is sleeping in wait(); used by exit().
// Caller must hold p->lock.
static void
wakeup1(struct proc *p)
{
  if(p->chan == p && p->state == SLEEPING) {
    80001d50:	4c05                	li	s8,1
    p->state = RUNNABLE;
    80001d52:	4c89                	li	s9,2
  for(pp = proc; pp < &proc[NPROC]; pp++){
    80001d54:	00015997          	auipc	s3,0x15
    80001d58:	7ac98993          	addi	s3,s3,1964 # 80017500 <tickslock>
    80001d5c:	a805                	j	80001d8c <reparent+0x74>
  if(p->chan == p && p->state == SLEEPING) {
    80001d5e:	751c                	ld	a5,40(a0)
    80001d60:	00f51d63          	bne	a0,a5,80001d7a <reparent+0x62>
    80001d64:	4d1c                	lw	a5,24(a0)
    80001d66:	01879a63          	bne	a5,s8,80001d7a <reparent+0x62>
    p->state = RUNNABLE;
    80001d6a:	01952c23          	sw	s9,24(a0)
        if(!child_of_init)
    80001d6e:	016b8663          	beq	s7,s6,80001d7a <reparent+0x62>
          release(&initproc->lock);
    80001d72:	fffff097          	auipc	ra,0xfffff
    80001d76:	df6080e7          	jalr	-522(ra) # 80000b68 <release>
      release(&pp->lock);
    80001d7a:	8526                	mv	a0,s1
    80001d7c:	fffff097          	auipc	ra,0xfffff
    80001d80:	dec080e7          	jalr	-532(ra) # 80000b68 <release>
  for(pp = proc; pp < &proc[NPROC]; pp++){
    80001d84:	16048493          	addi	s1,s1,352
    80001d88:	03348f63          	beq	s1,s3,80001dc6 <reparent+0xae>
    if(pp->parent == p){
    80001d8c:	709c                	ld	a5,32(s1)
    80001d8e:	ff279be3          	bne	a5,s2,80001d84 <reparent+0x6c>
      acquire(&pp->lock);
    80001d92:	8526                	mv	a0,s1
    80001d94:	fffff097          	auipc	ra,0xfffff
    80001d98:	d6c080e7          	jalr	-660(ra) # 80000b00 <acquire>
      pp->parent = initproc;
    80001d9c:	000a3503          	ld	a0,0(s4)
    80001da0:	f088                	sd	a0,32(s1)
      if(pp->state == ZOMBIE) {
    80001da2:	4c9c                	lw	a5,24(s1)
    80001da4:	fd579be3          	bne	a5,s5,80001d7a <reparent+0x62>
        if(!child_of_init)
    80001da8:	fb6b8be3          	beq	s7,s6,80001d5e <reparent+0x46>
          acquire(&initproc->lock);
    80001dac:	fffff097          	auipc	ra,0xfffff
    80001db0:	d54080e7          	jalr	-684(ra) # 80000b00 <acquire>
        wakeup1(initproc);
    80001db4:	000a3503          	ld	a0,0(s4)
  if(p->chan == p && p->state == SLEEPING) {
    80001db8:	751c                	ld	a5,40(a0)
    80001dba:	faa79ce3          	bne	a5,a0,80001d72 <reparent+0x5a>
    80001dbe:	4d1c                	lw	a5,24(a0)
    80001dc0:	fb8799e3          	bne	a5,s8,80001d72 <reparent+0x5a>
    80001dc4:	b75d                	j	80001d6a <reparent+0x52>
}
    80001dc6:	60e6                	ld	ra,88(sp)
    80001dc8:	6446                	ld	s0,80(sp)
    80001dca:	64a6                	ld	s1,72(sp)
    80001dcc:	6906                	ld	s2,64(sp)
    80001dce:	79e2                	ld	s3,56(sp)
    80001dd0:	7a42                	ld	s4,48(sp)
    80001dd2:	7aa2                	ld	s5,40(sp)
    80001dd4:	7b02                	ld	s6,32(sp)
    80001dd6:	6be2                	ld	s7,24(sp)
    80001dd8:	6c42                	ld	s8,16(sp)
    80001dda:	6ca2                	ld	s9,8(sp)
    80001ddc:	6125                	addi	sp,sp,96
    80001dde:	8082                	ret

0000000080001de0 <scheduler>:
{
    80001de0:	715d                	addi	sp,sp,-80
    80001de2:	e486                	sd	ra,72(sp)
    80001de4:	e0a2                	sd	s0,64(sp)
    80001de6:	fc26                	sd	s1,56(sp)
    80001de8:	f84a                	sd	s2,48(sp)
    80001dea:	f44e                	sd	s3,40(sp)
    80001dec:	f052                	sd	s4,32(sp)
    80001dee:	ec56                	sd	s5,24(sp)
    80001df0:	e85a                	sd	s6,16(sp)
    80001df2:	e45e                	sd	s7,8(sp)
    80001df4:	e062                	sd	s8,0(sp)
    80001df6:	0880                	addi	s0,sp,80
    80001df8:	8792                	mv	a5,tp
  int id = r_tp();
    80001dfa:	2781                	sext.w	a5,a5
  c->proc = 0;
    80001dfc:	00779b13          	slli	s6,a5,0x7
    80001e00:	00010717          	auipc	a4,0x10
    80001e04:	ae870713          	addi	a4,a4,-1304 # 800118e8 <pid_lock>
    80001e08:	975a                	add	a4,a4,s6
    80001e0a:	00073c23          	sd	zero,24(a4)
        swtch(&c->scheduler, &p->context);
    80001e0e:	00010717          	auipc	a4,0x10
    80001e12:	afa70713          	addi	a4,a4,-1286 # 80011908 <cpus+0x8>
    80001e16:	9b3a                	add	s6,s6,a4
        p->state = RUNNING;
    80001e18:	4c0d                	li	s8,3
        c->proc = p;
    80001e1a:	079e                	slli	a5,a5,0x7
    80001e1c:	00010a17          	auipc	s4,0x10
    80001e20:	acca0a13          	addi	s4,s4,-1332 # 800118e8 <pid_lock>
    80001e24:	9a3e                	add	s4,s4,a5
    for(p = proc; p < &proc[NPROC]; p++) {
    80001e26:	00015997          	auipc	s3,0x15
    80001e2a:	6da98993          	addi	s3,s3,1754 # 80017500 <tickslock>
        found = 1;
    80001e2e:	4b85                	li	s7,1
    80001e30:	a08d                	j	80001e92 <scheduler+0xb2>
        p->state = RUNNING;
    80001e32:	0184ac23          	sw	s8,24(s1)
        c->proc = p;
    80001e36:	009a3c23          	sd	s1,24(s4)
        swtch(&c->scheduler, &p->context);
    80001e3a:	05848593          	addi	a1,s1,88
    80001e3e:	855a                	mv	a0,s6
    80001e40:	00000097          	auipc	ra,0x0
    80001e44:	5f0080e7          	jalr	1520(ra) # 80002430 <swtch>
        c->proc = 0;
    80001e48:	000a3c23          	sd	zero,24(s4)
        found = 1;
    80001e4c:	8ade                	mv	s5,s7
      release(&p->lock);
    80001e4e:	8526                	mv	a0,s1
    80001e50:	fffff097          	auipc	ra,0xfffff
    80001e54:	d18080e7          	jalr	-744(ra) # 80000b68 <release>
    for(p = proc; p < &proc[NPROC]; p++) {
    80001e58:	16048493          	addi	s1,s1,352
    80001e5c:	01348b63          	beq	s1,s3,80001e72 <scheduler+0x92>
      acquire(&p->lock);
    80001e60:	8526                	mv	a0,s1
    80001e62:	fffff097          	auipc	ra,0xfffff
    80001e66:	c9e080e7          	jalr	-866(ra) # 80000b00 <acquire>
      if(p->state == RUNNABLE) {
    80001e6a:	4c9c                	lw	a5,24(s1)
    80001e6c:	ff2791e3          	bne	a5,s2,80001e4e <scheduler+0x6e>
    80001e70:	b7c9                	j	80001e32 <scheduler+0x52>
    if(found == 0){
    80001e72:	020a9063          	bnez	s5,80001e92 <scheduler+0xb2>
  asm volatile("csrr %0, sie" : "=r" (x) );
    80001e76:	104027f3          	csrr	a5,sie
  w_sie(r_sie() | SIE_SEIE | SIE_STIE | SIE_SSIE);
    80001e7a:	2227e793          	ori	a5,a5,546
  asm volatile("csrw sie, %0" : : "r" (x));
    80001e7e:	10479073          	csrw	sie,a5
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80001e82:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    80001e86:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80001e8a:	10079073          	csrw	sstatus,a5
      asm volatile("wfi");
    80001e8e:	10500073          	wfi
  asm volatile("csrr %0, sie" : "=r" (x) );
    80001e92:	104027f3          	csrr	a5,sie
  w_sie(r_sie() | SIE_SEIE | SIE_STIE | SIE_SSIE);
    80001e96:	2227e793          	ori	a5,a5,546
  asm volatile("csrw sie, %0" : : "r" (x));
    80001e9a:	10479073          	csrw	sie,a5
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80001e9e:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    80001ea2:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80001ea6:	10079073          	csrw	sstatus,a5
    int found = 0;
    80001eaa:	4a81                	li	s5,0
    for(p = proc; p < &proc[NPROC]; p++) {
    80001eac:	00010497          	auipc	s1,0x10
    80001eb0:	e5448493          	addi	s1,s1,-428 # 80011d00 <proc>
      if(p->state == RUNNABLE) {
    80001eb4:	4909                	li	s2,2
    80001eb6:	b76d                	j	80001e60 <scheduler+0x80>

0000000080001eb8 <sched>:
{
    80001eb8:	7179                	addi	sp,sp,-48
    80001eba:	f406                	sd	ra,40(sp)
    80001ebc:	f022                	sd	s0,32(sp)
    80001ebe:	ec26                	sd	s1,24(sp)
    80001ec0:	e84a                	sd	s2,16(sp)
    80001ec2:	e44e                	sd	s3,8(sp)
    80001ec4:	1800                	addi	s0,sp,48
  struct proc *p = myproc();
    80001ec6:	00000097          	auipc	ra,0x0
    80001eca:	9d8080e7          	jalr	-1576(ra) # 8000189e <myproc>
    80001ece:	892a                	mv	s2,a0
  if(!holding(&p->lock))
    80001ed0:	fffff097          	auipc	ra,0xfffff
    80001ed4:	bf0080e7          	jalr	-1040(ra) # 80000ac0 <holding>
    80001ed8:	cd25                	beqz	a0,80001f50 <sched+0x98>
  asm volatile("mv %0, tp" : "=r" (x) );
    80001eda:	8792                	mv	a5,tp
  if(mycpu()->noff != 1)
    80001edc:	2781                	sext.w	a5,a5
    80001ede:	079e                	slli	a5,a5,0x7
    80001ee0:	00010717          	auipc	a4,0x10
    80001ee4:	a0870713          	addi	a4,a4,-1528 # 800118e8 <pid_lock>
    80001ee8:	97ba                	add	a5,a5,a4
    80001eea:	0907a703          	lw	a4,144(a5)
    80001eee:	4785                	li	a5,1
    80001ef0:	06f71863          	bne	a4,a5,80001f60 <sched+0xa8>
  if(p->state == RUNNING)
    80001ef4:	01892703          	lw	a4,24(s2)
    80001ef8:	478d                	li	a5,3
    80001efa:	06f70b63          	beq	a4,a5,80001f70 <sched+0xb8>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80001efe:	100027f3          	csrr	a5,sstatus
  return (x & SSTATUS_SIE) != 0;
    80001f02:	8b89                	andi	a5,a5,2
  if(intr_get())
    80001f04:	efb5                	bnez	a5,80001f80 <sched+0xc8>
  asm volatile("mv %0, tp" : "=r" (x) );
    80001f06:	8792                	mv	a5,tp
  intena = mycpu()->intena;
    80001f08:	00010497          	auipc	s1,0x10
    80001f0c:	9e048493          	addi	s1,s1,-1568 # 800118e8 <pid_lock>
    80001f10:	2781                	sext.w	a5,a5
    80001f12:	079e                	slli	a5,a5,0x7
    80001f14:	97a6                	add	a5,a5,s1
    80001f16:	0947a983          	lw	s3,148(a5)
    80001f1a:	8792                	mv	a5,tp
  swtch(&p->context, &mycpu()->scheduler);
    80001f1c:	2781                	sext.w	a5,a5
    80001f1e:	079e                	slli	a5,a5,0x7
    80001f20:	00010597          	auipc	a1,0x10
    80001f24:	9e858593          	addi	a1,a1,-1560 # 80011908 <cpus+0x8>
    80001f28:	95be                	add	a1,a1,a5
    80001f2a:	05890513          	addi	a0,s2,88
    80001f2e:	00000097          	auipc	ra,0x0
    80001f32:	502080e7          	jalr	1282(ra) # 80002430 <swtch>
    80001f36:	8792                	mv	a5,tp
  mycpu()->intena = intena;
    80001f38:	2781                	sext.w	a5,a5
    80001f3a:	079e                	slli	a5,a5,0x7
    80001f3c:	97a6                	add	a5,a5,s1
    80001f3e:	0937aa23          	sw	s3,148(a5)
}
    80001f42:	70a2                	ld	ra,40(sp)
    80001f44:	7402                	ld	s0,32(sp)
    80001f46:	64e2                	ld	s1,24(sp)
    80001f48:	6942                	ld	s2,16(sp)
    80001f4a:	69a2                	ld	s3,8(sp)
    80001f4c:	6145                	addi	sp,sp,48
    80001f4e:	8082                	ret
    panic("sched p->lock");
    80001f50:	00005517          	auipc	a0,0x5
    80001f54:	3a850513          	addi	a0,a0,936 # 800072f8 <userret+0x268>
    80001f58:	ffffe097          	auipc	ra,0xffffe
    80001f5c:	626080e7          	jalr	1574(ra) # 8000057e <panic>
    panic("sched locks");
    80001f60:	00005517          	auipc	a0,0x5
    80001f64:	3a850513          	addi	a0,a0,936 # 80007308 <userret+0x278>
    80001f68:	ffffe097          	auipc	ra,0xffffe
    80001f6c:	616080e7          	jalr	1558(ra) # 8000057e <panic>
    panic("sched running");
    80001f70:	00005517          	auipc	a0,0x5
    80001f74:	3a850513          	addi	a0,a0,936 # 80007318 <userret+0x288>
    80001f78:	ffffe097          	auipc	ra,0xffffe
    80001f7c:	606080e7          	jalr	1542(ra) # 8000057e <panic>
    panic("sched interruptible");
    80001f80:	00005517          	auipc	a0,0x5
    80001f84:	3a850513          	addi	a0,a0,936 # 80007328 <userret+0x298>
    80001f88:	ffffe097          	auipc	ra,0xffffe
    80001f8c:	5f6080e7          	jalr	1526(ra) # 8000057e <panic>

0000000080001f90 <exit>:
{
    80001f90:	7179                	addi	sp,sp,-48
    80001f92:	f406                	sd	ra,40(sp)
    80001f94:	f022                	sd	s0,32(sp)
    80001f96:	ec26                	sd	s1,24(sp)
    80001f98:	e84a                	sd	s2,16(sp)
    80001f9a:	e44e                	sd	s3,8(sp)
    80001f9c:	1800                	addi	s0,sp,48
  struct proc *p = myproc();
    80001f9e:	00000097          	auipc	ra,0x0
    80001fa2:	900080e7          	jalr	-1792(ra) # 8000189e <myproc>
    80001fa6:	89aa                	mv	s3,a0
  if(p == initproc)
    80001fa8:	00027797          	auipc	a5,0x27
    80001fac:	07878793          	addi	a5,a5,120 # 80029020 <initproc>
    80001fb0:	639c                	ld	a5,0(a5)
    80001fb2:	0c850493          	addi	s1,a0,200
    80001fb6:	14850913          	addi	s2,a0,328
    80001fba:	02a79363          	bne	a5,a0,80001fe0 <exit+0x50>
    panic("init exiting");
    80001fbe:	00005517          	auipc	a0,0x5
    80001fc2:	38250513          	addi	a0,a0,898 # 80007340 <userret+0x2b0>
    80001fc6:	ffffe097          	auipc	ra,0xffffe
    80001fca:	5b8080e7          	jalr	1464(ra) # 8000057e <panic>
      fileclose(f);
    80001fce:	00002097          	auipc	ra,0x2
    80001fd2:	60c080e7          	jalr	1548(ra) # 800045da <fileclose>
      p->ofile[fd] = 0;
    80001fd6:	0004b023          	sd	zero,0(s1)
  for(int fd = 0; fd < NOFILE; fd++){
    80001fda:	04a1                	addi	s1,s1,8
    80001fdc:	01248563          	beq	s1,s2,80001fe6 <exit+0x56>
    if(p->ofile[fd]){
    80001fe0:	6088                	ld	a0,0(s1)
    80001fe2:	f575                	bnez	a0,80001fce <exit+0x3e>
    80001fe4:	bfdd                	j	80001fda <exit+0x4a>
  begin_op(ROOTDEV);
    80001fe6:	4501                	li	a0,0
    80001fe8:	00002097          	auipc	ra,0x2
    80001fec:	f98080e7          	jalr	-104(ra) # 80003f80 <begin_op>
  iput(p->cwd);
    80001ff0:	1489b503          	ld	a0,328(s3)
    80001ff4:	00001097          	auipc	ra,0x1
    80001ff8:	5ec080e7          	jalr	1516(ra) # 800035e0 <iput>
  end_op(ROOTDEV);
    80001ffc:	4501                	li	a0,0
    80001ffe:	00002097          	auipc	ra,0x2
    80002002:	02c080e7          	jalr	44(ra) # 8000402a <end_op>
  p->cwd = 0;
    80002006:	1409b423          	sd	zero,328(s3)
  acquire(&p->parent->lock);
    8000200a:	0209b503          	ld	a0,32(s3)
    8000200e:	fffff097          	auipc	ra,0xfffff
    80002012:	af2080e7          	jalr	-1294(ra) # 80000b00 <acquire>
  acquire(&p->lock);
    80002016:	854e                	mv	a0,s3
    80002018:	fffff097          	auipc	ra,0xfffff
    8000201c:	ae8080e7          	jalr	-1304(ra) # 80000b00 <acquire>
  reparent(p, p->parent);
    80002020:	0209b583          	ld	a1,32(s3)
    80002024:	854e                	mv	a0,s3
    80002026:	00000097          	auipc	ra,0x0
    8000202a:	cf2080e7          	jalr	-782(ra) # 80001d18 <reparent>
  wakeup1(p->parent);
    8000202e:	0209b783          	ld	a5,32(s3)
  if(p->chan == p && p->state == SLEEPING) {
    80002032:	7798                	ld	a4,40(a5)
    80002034:	02e78763          	beq	a5,a4,80002062 <exit+0xd2>
  p->state = ZOMBIE;
    80002038:	4791                	li	a5,4
    8000203a:	00f9ac23          	sw	a5,24(s3)
  release(&p->parent->lock);
    8000203e:	0209b503          	ld	a0,32(s3)
    80002042:	fffff097          	auipc	ra,0xfffff
    80002046:	b26080e7          	jalr	-1242(ra) # 80000b68 <release>
  sched();
    8000204a:	00000097          	auipc	ra,0x0
    8000204e:	e6e080e7          	jalr	-402(ra) # 80001eb8 <sched>
  panic("zombie exit");
    80002052:	00005517          	auipc	a0,0x5
    80002056:	2fe50513          	addi	a0,a0,766 # 80007350 <userret+0x2c0>
    8000205a:	ffffe097          	auipc	ra,0xffffe
    8000205e:	524080e7          	jalr	1316(ra) # 8000057e <panic>
  if(p->chan == p && p->state == SLEEPING) {
    80002062:	4f94                	lw	a3,24(a5)
    80002064:	4705                	li	a4,1
    80002066:	fce699e3          	bne	a3,a4,80002038 <exit+0xa8>
    p->state = RUNNABLE;
    8000206a:	4709                	li	a4,2
    8000206c:	cf98                	sw	a4,24(a5)
    8000206e:	b7e9                	j	80002038 <exit+0xa8>

0000000080002070 <yield>:
{
    80002070:	1101                	addi	sp,sp,-32
    80002072:	ec06                	sd	ra,24(sp)
    80002074:	e822                	sd	s0,16(sp)
    80002076:	e426                	sd	s1,8(sp)
    80002078:	1000                	addi	s0,sp,32
  struct proc *p = myproc();
    8000207a:	00000097          	auipc	ra,0x0
    8000207e:	824080e7          	jalr	-2012(ra) # 8000189e <myproc>
    80002082:	84aa                	mv	s1,a0
  acquire(&p->lock);
    80002084:	fffff097          	auipc	ra,0xfffff
    80002088:	a7c080e7          	jalr	-1412(ra) # 80000b00 <acquire>
  p->state = RUNNABLE;
    8000208c:	4789                	li	a5,2
    8000208e:	cc9c                	sw	a5,24(s1)
  sched();
    80002090:	00000097          	auipc	ra,0x0
    80002094:	e28080e7          	jalr	-472(ra) # 80001eb8 <sched>
  release(&p->lock);
    80002098:	8526                	mv	a0,s1
    8000209a:	fffff097          	auipc	ra,0xfffff
    8000209e:	ace080e7          	jalr	-1330(ra) # 80000b68 <release>
}
    800020a2:	60e2                	ld	ra,24(sp)
    800020a4:	6442                	ld	s0,16(sp)
    800020a6:	64a2                	ld	s1,8(sp)
    800020a8:	6105                	addi	sp,sp,32
    800020aa:	8082                	ret

00000000800020ac <sleep>:
{
    800020ac:	7179                	addi	sp,sp,-48
    800020ae:	f406                	sd	ra,40(sp)
    800020b0:	f022                	sd	s0,32(sp)
    800020b2:	ec26                	sd	s1,24(sp)
    800020b4:	e84a                	sd	s2,16(sp)
    800020b6:	e44e                	sd	s3,8(sp)
    800020b8:	1800                	addi	s0,sp,48
    800020ba:	89aa                	mv	s3,a0
    800020bc:	892e                	mv	s2,a1
  struct proc *p = myproc();
    800020be:	fffff097          	auipc	ra,0xfffff
    800020c2:	7e0080e7          	jalr	2016(ra) # 8000189e <myproc>
    800020c6:	84aa                	mv	s1,a0
  if(lk != &p->lock){  //DOC: sleeplock0
    800020c8:	05250663          	beq	a0,s2,80002114 <sleep+0x68>
    acquire(&p->lock);  //DOC: sleeplock1
    800020cc:	fffff097          	auipc	ra,0xfffff
    800020d0:	a34080e7          	jalr	-1484(ra) # 80000b00 <acquire>
    release(lk);
    800020d4:	854a                	mv	a0,s2
    800020d6:	fffff097          	auipc	ra,0xfffff
    800020da:	a92080e7          	jalr	-1390(ra) # 80000b68 <release>
  p->chan = chan;
    800020de:	0334b423          	sd	s3,40(s1)
  p->state = SLEEPING;
    800020e2:	4785                	li	a5,1
    800020e4:	cc9c                	sw	a5,24(s1)
  sched();
    800020e6:	00000097          	auipc	ra,0x0
    800020ea:	dd2080e7          	jalr	-558(ra) # 80001eb8 <sched>
  p->chan = 0;
    800020ee:	0204b423          	sd	zero,40(s1)
    release(&p->lock);
    800020f2:	8526                	mv	a0,s1
    800020f4:	fffff097          	auipc	ra,0xfffff
    800020f8:	a74080e7          	jalr	-1420(ra) # 80000b68 <release>
    acquire(lk);
    800020fc:	854a                	mv	a0,s2
    800020fe:	fffff097          	auipc	ra,0xfffff
    80002102:	a02080e7          	jalr	-1534(ra) # 80000b00 <acquire>
}
    80002106:	70a2                	ld	ra,40(sp)
    80002108:	7402                	ld	s0,32(sp)
    8000210a:	64e2                	ld	s1,24(sp)
    8000210c:	6942                	ld	s2,16(sp)
    8000210e:	69a2                	ld	s3,8(sp)
    80002110:	6145                	addi	sp,sp,48
    80002112:	8082                	ret
  p->chan = chan;
    80002114:	03353423          	sd	s3,40(a0)
  p->state = SLEEPING;
    80002118:	4785                	li	a5,1
    8000211a:	cd1c                	sw	a5,24(a0)
  sched();
    8000211c:	00000097          	auipc	ra,0x0
    80002120:	d9c080e7          	jalr	-612(ra) # 80001eb8 <sched>
  p->chan = 0;
    80002124:	0204b423          	sd	zero,40(s1)
  if(lk != &p->lock){
    80002128:	bff9                	j	80002106 <sleep+0x5a>

000000008000212a <wait>:
{
    8000212a:	715d                	addi	sp,sp,-80
    8000212c:	e486                	sd	ra,72(sp)
    8000212e:	e0a2                	sd	s0,64(sp)
    80002130:	fc26                	sd	s1,56(sp)
    80002132:	f84a                	sd	s2,48(sp)
    80002134:	f44e                	sd	s3,40(sp)
    80002136:	f052                	sd	s4,32(sp)
    80002138:	ec56                	sd	s5,24(sp)
    8000213a:	e85a                	sd	s6,16(sp)
    8000213c:	e45e                	sd	s7,8(sp)
    8000213e:	0880                	addi	s0,sp,80
  struct proc *p = myproc();
    80002140:	fffff097          	auipc	ra,0xfffff
    80002144:	75e080e7          	jalr	1886(ra) # 8000189e <myproc>
    80002148:	892a                	mv	s2,a0
  acquire(&p->lock);
    8000214a:	8baa                	mv	s7,a0
    8000214c:	fffff097          	auipc	ra,0xfffff
    80002150:	9b4080e7          	jalr	-1612(ra) # 80000b00 <acquire>
    havekids = 0;
    80002154:	4b01                	li	s6,0
        if(np->state == ZOMBIE){
    80002156:	4a11                	li	s4,4
    for(np = proc; np < &proc[NPROC]; np++){
    80002158:	00015997          	auipc	s3,0x15
    8000215c:	3a898993          	addi	s3,s3,936 # 80017500 <tickslock>
        havekids = 1;
    80002160:	4a85                	li	s5,1
    havekids = 0;
    80002162:	875a                	mv	a4,s6
    for(np = proc; np < &proc[NPROC]; np++){
    80002164:	00010497          	auipc	s1,0x10
    80002168:	b9c48493          	addi	s1,s1,-1124 # 80011d00 <proc>
    8000216c:	a03d                	j	8000219a <wait+0x70>
          pid = np->pid;
    8000216e:	0344a983          	lw	s3,52(s1)
          freeproc(np);
    80002172:	8526                	mv	a0,s1
    80002174:	00000097          	auipc	ra,0x0
    80002178:	948080e7          	jalr	-1720(ra) # 80001abc <freeproc>
          release(&np->lock);
    8000217c:	8526                	mv	a0,s1
    8000217e:	fffff097          	auipc	ra,0xfffff
    80002182:	9ea080e7          	jalr	-1558(ra) # 80000b68 <release>
          release(&p->lock);
    80002186:	854a                	mv	a0,s2
    80002188:	fffff097          	auipc	ra,0xfffff
    8000218c:	9e0080e7          	jalr	-1568(ra) # 80000b68 <release>
          return pid;
    80002190:	a089                	j	800021d2 <wait+0xa8>
    for(np = proc; np < &proc[NPROC]; np++){
    80002192:	16048493          	addi	s1,s1,352
    80002196:	03348463          	beq	s1,s3,800021be <wait+0x94>
      if(np->parent == p){
    8000219a:	709c                	ld	a5,32(s1)
    8000219c:	ff279be3          	bne	a5,s2,80002192 <wait+0x68>
        acquire(&np->lock);
    800021a0:	8526                	mv	a0,s1
    800021a2:	fffff097          	auipc	ra,0xfffff
    800021a6:	95e080e7          	jalr	-1698(ra) # 80000b00 <acquire>
        if(np->state == ZOMBIE){
    800021aa:	4c9c                	lw	a5,24(s1)
    800021ac:	fd4781e3          	beq	a5,s4,8000216e <wait+0x44>
        release(&np->lock);
    800021b0:	8526                	mv	a0,s1
    800021b2:	fffff097          	auipc	ra,0xfffff
    800021b6:	9b6080e7          	jalr	-1610(ra) # 80000b68 <release>
        havekids = 1;
    800021ba:	8756                	mv	a4,s5
    800021bc:	bfd9                	j	80002192 <wait+0x68>
    if(!havekids || p->killed){
    800021be:	c701                	beqz	a4,800021c6 <wait+0x9c>
    800021c0:	03092783          	lw	a5,48(s2)
    800021c4:	c39d                	beqz	a5,800021ea <wait+0xc0>
      release(&p->lock);
    800021c6:	854a                	mv	a0,s2
    800021c8:	fffff097          	auipc	ra,0xfffff
    800021cc:	9a0080e7          	jalr	-1632(ra) # 80000b68 <release>
      return -1;
    800021d0:	59fd                	li	s3,-1
}
    800021d2:	854e                	mv	a0,s3
    800021d4:	60a6                	ld	ra,72(sp)
    800021d6:	6406                	ld	s0,64(sp)
    800021d8:	74e2                	ld	s1,56(sp)
    800021da:	7942                	ld	s2,48(sp)
    800021dc:	79a2                	ld	s3,40(sp)
    800021de:	7a02                	ld	s4,32(sp)
    800021e0:	6ae2                	ld	s5,24(sp)
    800021e2:	6b42                	ld	s6,16(sp)
    800021e4:	6ba2                	ld	s7,8(sp)
    800021e6:	6161                	addi	sp,sp,80
    800021e8:	8082                	ret
    sleep(p, &p->lock);  //DOC: wait-sleep
    800021ea:	85de                	mv	a1,s7
    800021ec:	854a                	mv	a0,s2
    800021ee:	00000097          	auipc	ra,0x0
    800021f2:	ebe080e7          	jalr	-322(ra) # 800020ac <sleep>
    havekids = 0;
    800021f6:	b7b5                	j	80002162 <wait+0x38>

00000000800021f8 <wakeup>:
{
    800021f8:	7139                	addi	sp,sp,-64
    800021fa:	fc06                	sd	ra,56(sp)
    800021fc:	f822                	sd	s0,48(sp)
    800021fe:	f426                	sd	s1,40(sp)
    80002200:	f04a                	sd	s2,32(sp)
    80002202:	ec4e                	sd	s3,24(sp)
    80002204:	e852                	sd	s4,16(sp)
    80002206:	e456                	sd	s5,8(sp)
    80002208:	0080                	addi	s0,sp,64
    8000220a:	8a2a                	mv	s4,a0
  for(p = proc; p < &proc[NPROC]; p++) {
    8000220c:	00010497          	auipc	s1,0x10
    80002210:	af448493          	addi	s1,s1,-1292 # 80011d00 <proc>
    if(p->state == SLEEPING && p->chan == chan) {
    80002214:	4985                	li	s3,1
      p->state = RUNNABLE;
    80002216:	4a89                	li	s5,2
  for(p = proc; p < &proc[NPROC]; p++) {
    80002218:	00015917          	auipc	s2,0x15
    8000221c:	2e890913          	addi	s2,s2,744 # 80017500 <tickslock>
    80002220:	a821                	j	80002238 <wakeup+0x40>
      p->state = RUNNABLE;
    80002222:	0154ac23          	sw	s5,24(s1)
    release(&p->lock);
    80002226:	8526                	mv	a0,s1
    80002228:	fffff097          	auipc	ra,0xfffff
    8000222c:	940080e7          	jalr	-1728(ra) # 80000b68 <release>
  for(p = proc; p < &proc[NPROC]; p++) {
    80002230:	16048493          	addi	s1,s1,352
    80002234:	01248e63          	beq	s1,s2,80002250 <wakeup+0x58>
    acquire(&p->lock);
    80002238:	8526                	mv	a0,s1
    8000223a:	fffff097          	auipc	ra,0xfffff
    8000223e:	8c6080e7          	jalr	-1850(ra) # 80000b00 <acquire>
    if(p->state == SLEEPING && p->chan == chan) {
    80002242:	4c9c                	lw	a5,24(s1)
    80002244:	ff3791e3          	bne	a5,s3,80002226 <wakeup+0x2e>
    80002248:	749c                	ld	a5,40(s1)
    8000224a:	fd479ee3          	bne	a5,s4,80002226 <wakeup+0x2e>
    8000224e:	bfd1                	j	80002222 <wakeup+0x2a>
}
    80002250:	70e2                	ld	ra,56(sp)
    80002252:	7442                	ld	s0,48(sp)
    80002254:	74a2                	ld	s1,40(sp)
    80002256:	7902                	ld	s2,32(sp)
    80002258:	69e2                	ld	s3,24(sp)
    8000225a:	6a42                	ld	s4,16(sp)
    8000225c:	6aa2                	ld	s5,8(sp)
    8000225e:	6121                	addi	sp,sp,64
    80002260:	8082                	ret

0000000080002262 <kill>:
// Kill the process with the given pid.
// The victim won't exit until it tries to return
// to user space (see usertrap() in trap.c).
int
kill(int pid)
{
    80002262:	7179                	addi	sp,sp,-48
    80002264:	f406                	sd	ra,40(sp)
    80002266:	f022                	sd	s0,32(sp)
    80002268:	ec26                	sd	s1,24(sp)
    8000226a:	e84a                	sd	s2,16(sp)
    8000226c:	e44e                	sd	s3,8(sp)
    8000226e:	1800                	addi	s0,sp,48
    80002270:	892a                	mv	s2,a0
  struct proc *p;

  for(p = proc; p < &proc[NPROC]; p++){
    80002272:	00010497          	auipc	s1,0x10
    80002276:	a8e48493          	addi	s1,s1,-1394 # 80011d00 <proc>
    8000227a:	00015997          	auipc	s3,0x15
    8000227e:	28698993          	addi	s3,s3,646 # 80017500 <tickslock>
    acquire(&p->lock);
    80002282:	8526                	mv	a0,s1
    80002284:	fffff097          	auipc	ra,0xfffff
    80002288:	87c080e7          	jalr	-1924(ra) # 80000b00 <acquire>
    if(p->pid == pid){
    8000228c:	58dc                	lw	a5,52(s1)
    8000228e:	01278d63          	beq	a5,s2,800022a8 <kill+0x46>
        p->state = RUNNABLE;
      }
      release(&p->lock);
      return 0;
    }
    release(&p->lock);
    80002292:	8526                	mv	a0,s1
    80002294:	fffff097          	auipc	ra,0xfffff
    80002298:	8d4080e7          	jalr	-1836(ra) # 80000b68 <release>
  for(p = proc; p < &proc[NPROC]; p++){
    8000229c:	16048493          	addi	s1,s1,352
    800022a0:	ff3491e3          	bne	s1,s3,80002282 <kill+0x20>
  }
  return -1;
    800022a4:	557d                	li	a0,-1
    800022a6:	a829                	j	800022c0 <kill+0x5e>
      p->killed = 1;
    800022a8:	4785                	li	a5,1
    800022aa:	d89c                	sw	a5,48(s1)
      if(p->state == SLEEPING){
    800022ac:	4c98                	lw	a4,24(s1)
    800022ae:	4785                	li	a5,1
    800022b0:	00f70f63          	beq	a4,a5,800022ce <kill+0x6c>
      release(&p->lock);
    800022b4:	8526                	mv	a0,s1
    800022b6:	fffff097          	auipc	ra,0xfffff
    800022ba:	8b2080e7          	jalr	-1870(ra) # 80000b68 <release>
      return 0;
    800022be:	4501                	li	a0,0
}
    800022c0:	70a2                	ld	ra,40(sp)
    800022c2:	7402                	ld	s0,32(sp)
    800022c4:	64e2                	ld	s1,24(sp)
    800022c6:	6942                	ld	s2,16(sp)
    800022c8:	69a2                	ld	s3,8(sp)
    800022ca:	6145                	addi	sp,sp,48
    800022cc:	8082                	ret
        p->state = RUNNABLE;
    800022ce:	4789                	li	a5,2
    800022d0:	cc9c                	sw	a5,24(s1)
    800022d2:	b7cd                	j	800022b4 <kill+0x52>

00000000800022d4 <either_copyout>:
// Copy to either a user address, or kernel address,
// depending on usr_dst.
// Returns 0 on success, -1 on error.
int
either_copyout(int user_dst, uint64 dst, void *src, uint64 len)
{
    800022d4:	7179                	addi	sp,sp,-48
    800022d6:	f406                	sd	ra,40(sp)
    800022d8:	f022                	sd	s0,32(sp)
    800022da:	ec26                	sd	s1,24(sp)
    800022dc:	e84a                	sd	s2,16(sp)
    800022de:	e44e                	sd	s3,8(sp)
    800022e0:	e052                	sd	s4,0(sp)
    800022e2:	1800                	addi	s0,sp,48
    800022e4:	84aa                	mv	s1,a0
    800022e6:	892e                	mv	s2,a1
    800022e8:	89b2                	mv	s3,a2
    800022ea:	8a36                	mv	s4,a3
  struct proc *p = myproc();
    800022ec:	fffff097          	auipc	ra,0xfffff
    800022f0:	5b2080e7          	jalr	1458(ra) # 8000189e <myproc>
  if(user_dst){
    800022f4:	c08d                	beqz	s1,80002316 <either_copyout+0x42>
    return copyout(p->pagetable, dst, src, len);
    800022f6:	86d2                	mv	a3,s4
    800022f8:	864e                	mv	a2,s3
    800022fa:	85ca                	mv	a1,s2
    800022fc:	6528                	ld	a0,72(a0)
    800022fe:	fffff097          	auipc	ra,0xfffff
    80002302:	2ae080e7          	jalr	686(ra) # 800015ac <copyout>
  } else {
    memmove((char *)dst, src, len);
    return 0;
  }
}
    80002306:	70a2                	ld	ra,40(sp)
    80002308:	7402                	ld	s0,32(sp)
    8000230a:	64e2                	ld	s1,24(sp)
    8000230c:	6942                	ld	s2,16(sp)
    8000230e:	69a2                	ld	s3,8(sp)
    80002310:	6a02                	ld	s4,0(sp)
    80002312:	6145                	addi	sp,sp,48
    80002314:	8082                	ret
    memmove((char *)dst, src, len);
    80002316:	000a061b          	sext.w	a2,s4
    8000231a:	85ce                	mv	a1,s3
    8000231c:	854a                	mv	a0,s2
    8000231e:	fffff097          	auipc	ra,0xfffff
    80002322:	914080e7          	jalr	-1772(ra) # 80000c32 <memmove>
    return 0;
    80002326:	8526                	mv	a0,s1
    80002328:	bff9                	j	80002306 <either_copyout+0x32>

000000008000232a <either_copyin>:
// Copy from either a user address, or kernel address,
// depending on usr_src.
// Returns 0 on success, -1 on error.
int
either_copyin(void *dst, int user_src, uint64 src, uint64 len)
{
    8000232a:	7179                	addi	sp,sp,-48
    8000232c:	f406                	sd	ra,40(sp)
    8000232e:	f022                	sd	s0,32(sp)
    80002330:	ec26                	sd	s1,24(sp)
    80002332:	e84a                	sd	s2,16(sp)
    80002334:	e44e                	sd	s3,8(sp)
    80002336:	e052                	sd	s4,0(sp)
    80002338:	1800                	addi	s0,sp,48
    8000233a:	892a                	mv	s2,a0
    8000233c:	84ae                	mv	s1,a1
    8000233e:	89b2                	mv	s3,a2
    80002340:	8a36                	mv	s4,a3
  struct proc *p = myproc();
    80002342:	fffff097          	auipc	ra,0xfffff
    80002346:	55c080e7          	jalr	1372(ra) # 8000189e <myproc>
  if(user_src){
    8000234a:	c08d                	beqz	s1,8000236c <either_copyin+0x42>
    return copyin(p->pagetable, dst, src, len);
    8000234c:	86d2                	mv	a3,s4
    8000234e:	864e                	mv	a2,s3
    80002350:	85ca                	mv	a1,s2
    80002352:	6528                	ld	a0,72(a0)
    80002354:	fffff097          	auipc	ra,0xfffff
    80002358:	2ea080e7          	jalr	746(ra) # 8000163e <copyin>
  } else {
    memmove(dst, (char*)src, len);
    return 0;
  }
}
    8000235c:	70a2                	ld	ra,40(sp)
    8000235e:	7402                	ld	s0,32(sp)
    80002360:	64e2                	ld	s1,24(sp)
    80002362:	6942                	ld	s2,16(sp)
    80002364:	69a2                	ld	s3,8(sp)
    80002366:	6a02                	ld	s4,0(sp)
    80002368:	6145                	addi	sp,sp,48
    8000236a:	8082                	ret
    memmove(dst, (char*)src, len);
    8000236c:	000a061b          	sext.w	a2,s4
    80002370:	85ce                	mv	a1,s3
    80002372:	854a                	mv	a0,s2
    80002374:	fffff097          	auipc	ra,0xfffff
    80002378:	8be080e7          	jalr	-1858(ra) # 80000c32 <memmove>
    return 0;
    8000237c:	8526                	mv	a0,s1
    8000237e:	bff9                	j	8000235c <either_copyin+0x32>

0000000080002380 <procdump>:
// Print a process listing to console.  For debugging.
// Runs when user types ^P on console.
// No lock to avoid wedging a stuck machine further.
void
procdump(void)
{
    80002380:	715d                	addi	sp,sp,-80
    80002382:	e486                	sd	ra,72(sp)
    80002384:	e0a2                	sd	s0,64(sp)
    80002386:	fc26                	sd	s1,56(sp)
    80002388:	f84a                	sd	s2,48(sp)
    8000238a:	f44e                	sd	s3,40(sp)
    8000238c:	f052                	sd	s4,32(sp)
    8000238e:	ec56                	sd	s5,24(sp)
    80002390:	e85a                	sd	s6,16(sp)
    80002392:	e45e                	sd	s7,8(sp)
    80002394:	0880                	addi	s0,sp,80
  [ZOMBIE]    "zombie"
  };
  struct proc *p;
  char *state;

  printf("\n");
    80002396:	00005517          	auipc	a0,0x5
    8000239a:	e1a50513          	addi	a0,a0,-486 # 800071b0 <userret+0x120>
    8000239e:	ffffe097          	auipc	ra,0xffffe
    800023a2:	22a080e7          	jalr	554(ra) # 800005c8 <printf>
  for(p = proc; p < &proc[NPROC]; p++){
    800023a6:	00010497          	auipc	s1,0x10
    800023aa:	aaa48493          	addi	s1,s1,-1366 # 80011e50 <proc+0x150>
    800023ae:	00015917          	auipc	s2,0x15
    800023b2:	2a290913          	addi	s2,s2,674 # 80017650 <bcache+0x138>
    if(p->state == UNUSED)
      continue;
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
    800023b6:	4b11                	li	s6,4
      state = states[p->state];
    else
      state = "???";
    800023b8:	00005997          	auipc	s3,0x5
    800023bc:	fa898993          	addi	s3,s3,-88 # 80007360 <userret+0x2d0>
    printf("%d %s %s", p->pid, state, p->name);
    800023c0:	00005a97          	auipc	s5,0x5
    800023c4:	fa8a8a93          	addi	s5,s5,-88 # 80007368 <userret+0x2d8>
    printf("\n");
    800023c8:	00005a17          	auipc	s4,0x5
    800023cc:	de8a0a13          	addi	s4,s4,-536 # 800071b0 <userret+0x120>
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
    800023d0:	00005b97          	auipc	s7,0x5
    800023d4:	518b8b93          	addi	s7,s7,1304 # 800078e8 <states.1779>
    800023d8:	a015                	j	800023fc <procdump+0x7c>
    printf("%d %s %s", p->pid, state, p->name);
    800023da:	86ba                	mv	a3,a4
    800023dc:	ee472583          	lw	a1,-284(a4)
    800023e0:	8556                	mv	a0,s5
    800023e2:	ffffe097          	auipc	ra,0xffffe
    800023e6:	1e6080e7          	jalr	486(ra) # 800005c8 <printf>
    printf("\n");
    800023ea:	8552                	mv	a0,s4
    800023ec:	ffffe097          	auipc	ra,0xffffe
    800023f0:	1dc080e7          	jalr	476(ra) # 800005c8 <printf>
  for(p = proc; p < &proc[NPROC]; p++){
    800023f4:	16048493          	addi	s1,s1,352
    800023f8:	03248163          	beq	s1,s2,8000241a <procdump+0x9a>
    if(p->state == UNUSED)
    800023fc:	8726                	mv	a4,s1
    800023fe:	ec84a783          	lw	a5,-312(s1)
    80002402:	dbed                	beqz	a5,800023f4 <procdump+0x74>
      state = "???";
    80002404:	864e                	mv	a2,s3
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
    80002406:	fcfb6ae3          	bltu	s6,a5,800023da <procdump+0x5a>
    8000240a:	1782                	slli	a5,a5,0x20
    8000240c:	9381                	srli	a5,a5,0x20
    8000240e:	078e                	slli	a5,a5,0x3
    80002410:	97de                	add	a5,a5,s7
    80002412:	6390                	ld	a2,0(a5)
    80002414:	f279                	bnez	a2,800023da <procdump+0x5a>
      state = "???";
    80002416:	864e                	mv	a2,s3
    80002418:	b7c9                	j	800023da <procdump+0x5a>
  }
}
    8000241a:	60a6                	ld	ra,72(sp)
    8000241c:	6406                	ld	s0,64(sp)
    8000241e:	74e2                	ld	s1,56(sp)
    80002420:	7942                	ld	s2,48(sp)
    80002422:	79a2                	ld	s3,40(sp)
    80002424:	7a02                	ld	s4,32(sp)
    80002426:	6ae2                	ld	s5,24(sp)
    80002428:	6b42                	ld	s6,16(sp)
    8000242a:	6ba2                	ld	s7,8(sp)
    8000242c:	6161                	addi	sp,sp,80
    8000242e:	8082                	ret

0000000080002430 <swtch>:
    80002430:	00153023          	sd	ra,0(a0)
    80002434:	00253423          	sd	sp,8(a0)
    80002438:	e900                	sd	s0,16(a0)
    8000243a:	ed04                	sd	s1,24(a0)
    8000243c:	03253023          	sd	s2,32(a0)
    80002440:	03353423          	sd	s3,40(a0)
    80002444:	03453823          	sd	s4,48(a0)
    80002448:	03553c23          	sd	s5,56(a0)
    8000244c:	05653023          	sd	s6,64(a0)
    80002450:	05753423          	sd	s7,72(a0)
    80002454:	05853823          	sd	s8,80(a0)
    80002458:	05953c23          	sd	s9,88(a0)
    8000245c:	07a53023          	sd	s10,96(a0)
    80002460:	07b53423          	sd	s11,104(a0)
    80002464:	0005b083          	ld	ra,0(a1)
    80002468:	0085b103          	ld	sp,8(a1)
    8000246c:	6980                	ld	s0,16(a1)
    8000246e:	6d84                	ld	s1,24(a1)
    80002470:	0205b903          	ld	s2,32(a1)
    80002474:	0285b983          	ld	s3,40(a1)
    80002478:	0305ba03          	ld	s4,48(a1)
    8000247c:	0385ba83          	ld	s5,56(a1)
    80002480:	0405bb03          	ld	s6,64(a1)
    80002484:	0485bb83          	ld	s7,72(a1)
    80002488:	0505bc03          	ld	s8,80(a1)
    8000248c:	0585bc83          	ld	s9,88(a1)
    80002490:	0605bd03          	ld	s10,96(a1)
    80002494:	0685bd83          	ld	s11,104(a1)
    80002498:	8082                	ret

000000008000249a <trapinit>:

extern int devintr();

void
trapinit(void)
{
    8000249a:	1141                	addi	sp,sp,-16
    8000249c:	e406                	sd	ra,8(sp)
    8000249e:	e022                	sd	s0,0(sp)
    800024a0:	0800                	addi	s0,sp,16
  initlock(&tickslock, "time");
    800024a2:	00005597          	auipc	a1,0x5
    800024a6:	efe58593          	addi	a1,a1,-258 # 800073a0 <userret+0x310>
    800024aa:	00015517          	auipc	a0,0x15
    800024ae:	05650513          	addi	a0,a0,86 # 80017500 <tickslock>
    800024b2:	ffffe097          	auipc	ra,0xffffe
    800024b6:	540080e7          	jalr	1344(ra) # 800009f2 <initlock>
}
    800024ba:	60a2                	ld	ra,8(sp)
    800024bc:	6402                	ld	s0,0(sp)
    800024be:	0141                	addi	sp,sp,16
    800024c0:	8082                	ret

00000000800024c2 <trapinithart>:

// set up to take exceptions and traps while in the kernel.
void
trapinithart(void)
{
    800024c2:	1141                	addi	sp,sp,-16
    800024c4:	e422                	sd	s0,8(sp)
    800024c6:	0800                	addi	s0,sp,16
  asm volatile("csrw stvec, %0" : : "r" (x));
    800024c8:	00004797          	auipc	a5,0x4
    800024cc:	80878793          	addi	a5,a5,-2040 # 80005cd0 <kernelvec>
    800024d0:	10579073          	csrw	stvec,a5
  w_stvec((uint64)kernelvec);
}
    800024d4:	6422                	ld	s0,8(sp)
    800024d6:	0141                	addi	sp,sp,16
    800024d8:	8082                	ret

00000000800024da <usertrapret>:
//
// return to user space
//
void
usertrapret(void)
{
    800024da:	1141                	addi	sp,sp,-16
    800024dc:	e406                	sd	ra,8(sp)
    800024de:	e022                	sd	s0,0(sp)
    800024e0:	0800                	addi	s0,sp,16
  struct proc *p = myproc();
    800024e2:	fffff097          	auipc	ra,0xfffff
    800024e6:	3bc080e7          	jalr	956(ra) # 8000189e <myproc>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    800024ea:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() & ~SSTATUS_SIE);
    800024ee:	9bf5                	andi	a5,a5,-3
  asm volatile("csrw sstatus, %0" : : "r" (x));
    800024f0:	10079073          	csrw	sstatus,a5
  // turn off interrupts, since we're switching
  // now from kerneltrap() to usertrap().
  intr_off();

  // send interrupts and exceptions to trampoline.S
  w_stvec(TRAMPOLINE + (uservec - trampoline));
    800024f4:	00005617          	auipc	a2,0x5
    800024f8:	b0c60613          	addi	a2,a2,-1268 # 80007000 <trampoline>
    800024fc:	00005697          	auipc	a3,0x5
    80002500:	b0468693          	addi	a3,a3,-1276 # 80007000 <trampoline>
    80002504:	8e91                	sub	a3,a3,a2
    80002506:	040007b7          	lui	a5,0x4000
    8000250a:	17fd                	addi	a5,a5,-1
    8000250c:	07b2                	slli	a5,a5,0xc
    8000250e:	96be                	add	a3,a3,a5
  asm volatile("csrw stvec, %0" : : "r" (x));
    80002510:	10569073          	csrw	stvec,a3

  // set up values that uservec will need when
  // the process next re-enters the kernel.
  p->tf->kernel_satp = r_satp();         // kernel page table
    80002514:	6938                	ld	a4,80(a0)
  asm volatile("csrr %0, satp" : "=r" (x) );
    80002516:	180026f3          	csrr	a3,satp
    8000251a:	e314                	sd	a3,0(a4)
  p->tf->kernel_sp = p->kstack + PGSIZE; // process's kernel stack
    8000251c:	6938                	ld	a4,80(a0)
    8000251e:	7d14                	ld	a3,56(a0)
    80002520:	6585                	lui	a1,0x1
    80002522:	96ae                	add	a3,a3,a1
    80002524:	e714                	sd	a3,8(a4)
  p->tf->kernel_trap = (uint64)usertrap;
    80002526:	6938                	ld	a4,80(a0)
    80002528:	00000697          	auipc	a3,0x0
    8000252c:	12868693          	addi	a3,a3,296 # 80002650 <usertrap>
    80002530:	eb14                	sd	a3,16(a4)
  p->tf->kernel_hartid = r_tp();         // hartid for cpuid()
    80002532:	6938                	ld	a4,80(a0)
  asm volatile("mv %0, tp" : "=r" (x) );
    80002534:	8692                	mv	a3,tp
    80002536:	f314                	sd	a3,32(a4)
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80002538:	100026f3          	csrr	a3,sstatus
  // set up the registers that trampoline.S's sret will use
  // to get to user space.
  
  // set S Previous Privilege mode to User.
  unsigned long x = r_sstatus();
  x &= ~SSTATUS_SPP; // clear SPP to 0 for user mode
    8000253c:	eff6f693          	andi	a3,a3,-257
  x |= SSTATUS_SPIE; // enable interrupts in user mode
    80002540:	0206e693          	ori	a3,a3,32
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80002544:	10069073          	csrw	sstatus,a3
  w_sstatus(x);

  // set S Exception Program Counter to the saved user pc.
  w_sepc(p->tf->epc);
    80002548:	6938                	ld	a4,80(a0)
  asm volatile("csrw sepc, %0" : : "r" (x));
    8000254a:	6f18                	ld	a4,24(a4)
    8000254c:	14171073          	csrw	sepc,a4

  // tell trampoline.S the user page table to switch to.
  uint64 satp = MAKE_SATP(p->pagetable);
    80002550:	652c                	ld	a1,72(a0)
    80002552:	81b1                	srli	a1,a1,0xc

  // jump to trampoline.S at the top of memory, which 
  // switches to the user page table, restores user registers,
  // and switches to user mode with sret.
  uint64 fn = TRAMPOLINE + (userret - trampoline);
    80002554:	00005717          	auipc	a4,0x5
    80002558:	b3c70713          	addi	a4,a4,-1220 # 80007090 <userret>
    8000255c:	8f11                	sub	a4,a4,a2
    8000255e:	97ba                	add	a5,a5,a4
  ((void (*)(uint64,uint64))fn)(TRAPFRAME, satp);
    80002560:	577d                	li	a4,-1
    80002562:	177e                	slli	a4,a4,0x3f
    80002564:	8dd9                	or	a1,a1,a4
    80002566:	02000537          	lui	a0,0x2000
    8000256a:	157d                	addi	a0,a0,-1
    8000256c:	0536                	slli	a0,a0,0xd
    8000256e:	9782                	jalr	a5
}
    80002570:	60a2                	ld	ra,8(sp)
    80002572:	6402                	ld	s0,0(sp)
    80002574:	0141                	addi	sp,sp,16
    80002576:	8082                	ret

0000000080002578 <clockintr>:
  w_sstatus(sstatus);
}

void
clockintr()
{
    80002578:	1101                	addi	sp,sp,-32
    8000257a:	ec06                	sd	ra,24(sp)
    8000257c:	e822                	sd	s0,16(sp)
    8000257e:	e426                	sd	s1,8(sp)
    80002580:	1000                	addi	s0,sp,32
  acquire(&tickslock);
    80002582:	00015497          	auipc	s1,0x15
    80002586:	f7e48493          	addi	s1,s1,-130 # 80017500 <tickslock>
    8000258a:	8526                	mv	a0,s1
    8000258c:	ffffe097          	auipc	ra,0xffffe
    80002590:	574080e7          	jalr	1396(ra) # 80000b00 <acquire>
  ticks++;
    80002594:	00027517          	auipc	a0,0x27
    80002598:	a9450513          	addi	a0,a0,-1388 # 80029028 <ticks>
    8000259c:	411c                	lw	a5,0(a0)
    8000259e:	2785                	addiw	a5,a5,1
    800025a0:	c11c                	sw	a5,0(a0)
  wakeup(&ticks);
    800025a2:	00000097          	auipc	ra,0x0
    800025a6:	c56080e7          	jalr	-938(ra) # 800021f8 <wakeup>
  release(&tickslock);
    800025aa:	8526                	mv	a0,s1
    800025ac:	ffffe097          	auipc	ra,0xffffe
    800025b0:	5bc080e7          	jalr	1468(ra) # 80000b68 <release>
}
    800025b4:	60e2                	ld	ra,24(sp)
    800025b6:	6442                	ld	s0,16(sp)
    800025b8:	64a2                	ld	s1,8(sp)
    800025ba:	6105                	addi	sp,sp,32
    800025bc:	8082                	ret

00000000800025be <devintr>:
// returns 2 if timer interrupt,
// 1 if other device,
// 0 if not recognized.
int
devintr()
{
    800025be:	1101                	addi	sp,sp,-32
    800025c0:	ec06                	sd	ra,24(sp)
    800025c2:	e822                	sd	s0,16(sp)
    800025c4:	e426                	sd	s1,8(sp)
    800025c6:	1000                	addi	s0,sp,32
  asm volatile("csrr %0, scause" : "=r" (x) );
    800025c8:	14202773          	csrr	a4,scause
  uint64 scause = r_scause();

  if((scause & 0x8000000000000000L) &&
    800025cc:	00074d63          	bltz	a4,800025e6 <devintr+0x28>
      virtio_disk_intr(irq - VIRTIO0_IRQ);
    }

    plic_complete(irq);
    return 1;
  } else if(scause == 0x8000000000000001L){
    800025d0:	57fd                	li	a5,-1
    800025d2:	17fe                	slli	a5,a5,0x3f
    800025d4:	0785                	addi	a5,a5,1
    // the SSIP bit in sip.
    w_sip(r_sip() & ~2);

    return 2;
  } else {
    return 0;
    800025d6:	4501                	li	a0,0
  } else if(scause == 0x8000000000000001L){
    800025d8:	04f70b63          	beq	a4,a5,8000262e <devintr+0x70>
  }
}
    800025dc:	60e2                	ld	ra,24(sp)
    800025de:	6442                	ld	s0,16(sp)
    800025e0:	64a2                	ld	s1,8(sp)
    800025e2:	6105                	addi	sp,sp,32
    800025e4:	8082                	ret
     (scause & 0xff) == 9){
    800025e6:	0ff77793          	andi	a5,a4,255
  if((scause & 0x8000000000000000L) &&
    800025ea:	46a5                	li	a3,9
    800025ec:	fed792e3          	bne	a5,a3,800025d0 <devintr+0x12>
    int irq = plic_claim();
    800025f0:	00003097          	auipc	ra,0x3
    800025f4:	7fa080e7          	jalr	2042(ra) # 80005dea <plic_claim>
    800025f8:	84aa                	mv	s1,a0
    if(irq == UART0_IRQ){
    800025fa:	47a9                	li	a5,10
    800025fc:	00f50e63          	beq	a0,a5,80002618 <devintr+0x5a>
    } else if(irq == VIRTIO0_IRQ || irq == VIRTIO1_IRQ ){
    80002600:	fff5079b          	addiw	a5,a0,-1
    80002604:	4705                	li	a4,1
    80002606:	00f77e63          	bleu	a5,a4,80002622 <devintr+0x64>
    plic_complete(irq);
    8000260a:	8526                	mv	a0,s1
    8000260c:	00004097          	auipc	ra,0x4
    80002610:	802080e7          	jalr	-2046(ra) # 80005e0e <plic_complete>
    return 1;
    80002614:	4505                	li	a0,1
    80002616:	b7d9                	j	800025dc <devintr+0x1e>
      uartintr();
    80002618:	ffffe097          	auipc	ra,0xffffe
    8000261c:	250080e7          	jalr	592(ra) # 80000868 <uartintr>
    80002620:	b7ed                	j	8000260a <devintr+0x4c>
      virtio_disk_intr(irq - VIRTIO0_IRQ);
    80002622:	853e                	mv	a0,a5
    80002624:	00004097          	auipc	ra,0x4
    80002628:	dbc080e7          	jalr	-580(ra) # 800063e0 <virtio_disk_intr>
    8000262c:	bff9                	j	8000260a <devintr+0x4c>
    if(cpuid() == 0){
    8000262e:	fffff097          	auipc	ra,0xfffff
    80002632:	244080e7          	jalr	580(ra) # 80001872 <cpuid>
    80002636:	c901                	beqz	a0,80002646 <devintr+0x88>
  asm volatile("csrr %0, sip" : "=r" (x) );
    80002638:	144027f3          	csrr	a5,sip
    w_sip(r_sip() & ~2);
    8000263c:	9bf5                	andi	a5,a5,-3
  asm volatile("csrw sip, %0" : : "r" (x));
    8000263e:	14479073          	csrw	sip,a5
    return 2;
    80002642:	4509                	li	a0,2
    80002644:	bf61                	j	800025dc <devintr+0x1e>
      clockintr();
    80002646:	00000097          	auipc	ra,0x0
    8000264a:	f32080e7          	jalr	-206(ra) # 80002578 <clockintr>
    8000264e:	b7ed                	j	80002638 <devintr+0x7a>

0000000080002650 <usertrap>:
{
    80002650:	1101                	addi	sp,sp,-32
    80002652:	ec06                	sd	ra,24(sp)
    80002654:	e822                	sd	s0,16(sp)
    80002656:	e426                	sd	s1,8(sp)
    80002658:	e04a                	sd	s2,0(sp)
    8000265a:	1000                	addi	s0,sp,32
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    8000265c:	100027f3          	csrr	a5,sstatus
  if((r_sstatus() & SSTATUS_SPP) != 0)
    80002660:	1007f793          	andi	a5,a5,256
    80002664:	e7bd                	bnez	a5,800026d2 <usertrap+0x82>
  asm volatile("csrw stvec, %0" : : "r" (x));
    80002666:	00003797          	auipc	a5,0x3
    8000266a:	66a78793          	addi	a5,a5,1642 # 80005cd0 <kernelvec>
    8000266e:	10579073          	csrw	stvec,a5
  struct proc *p = myproc();
    80002672:	fffff097          	auipc	ra,0xfffff
    80002676:	22c080e7          	jalr	556(ra) # 8000189e <myproc>
    8000267a:	84aa                	mv	s1,a0
  p->tf->epc = r_sepc();
    8000267c:	693c                	ld	a5,80(a0)
  asm volatile("csrr %0, sepc" : "=r" (x) );
    8000267e:	14102773          	csrr	a4,sepc
    80002682:	ef98                	sd	a4,24(a5)
  asm volatile("csrr %0, scause" : "=r" (x) );
    80002684:	14202773          	csrr	a4,scause
  if(r_scause() == 8){
    80002688:	47a1                	li	a5,8
    8000268a:	06f71163          	bne	a4,a5,800026ec <usertrap+0x9c>
    if(p->killed)
    8000268e:	591c                	lw	a5,48(a0)
    80002690:	eba9                	bnez	a5,800026e2 <usertrap+0x92>
    p->tf->epc += 4;
    80002692:	68b8                	ld	a4,80(s1)
    80002694:	6f1c                	ld	a5,24(a4)
    80002696:	0791                	addi	a5,a5,4
    80002698:	ef1c                	sd	a5,24(a4)
  asm volatile("csrr %0, sie" : "=r" (x) );
    8000269a:	104027f3          	csrr	a5,sie
  w_sie(r_sie() | SIE_SEIE | SIE_STIE | SIE_SSIE);
    8000269e:	2227e793          	ori	a5,a5,546
  asm volatile("csrw sie, %0" : : "r" (x));
    800026a2:	10479073          	csrw	sie,a5
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    800026a6:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    800026aa:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    800026ae:	10079073          	csrw	sstatus,a5
    syscall();
    800026b2:	00000097          	auipc	ra,0x0
    800026b6:	2e2080e7          	jalr	738(ra) # 80002994 <syscall>
  if(p->killed)
    800026ba:	589c                	lw	a5,48(s1)
    800026bc:	e7d1                	bnez	a5,80002748 <usertrap+0xf8>
  usertrapret();
    800026be:	00000097          	auipc	ra,0x0
    800026c2:	e1c080e7          	jalr	-484(ra) # 800024da <usertrapret>
}
    800026c6:	60e2                	ld	ra,24(sp)
    800026c8:	6442                	ld	s0,16(sp)
    800026ca:	64a2                	ld	s1,8(sp)
    800026cc:	6902                	ld	s2,0(sp)
    800026ce:	6105                	addi	sp,sp,32
    800026d0:	8082                	ret
    panic("usertrap: not from user mode");
    800026d2:	00005517          	auipc	a0,0x5
    800026d6:	cd650513          	addi	a0,a0,-810 # 800073a8 <userret+0x318>
    800026da:	ffffe097          	auipc	ra,0xffffe
    800026de:	ea4080e7          	jalr	-348(ra) # 8000057e <panic>
      exit();
    800026e2:	00000097          	auipc	ra,0x0
    800026e6:	8ae080e7          	jalr	-1874(ra) # 80001f90 <exit>
    800026ea:	b765                	j	80002692 <usertrap+0x42>
  } else if((which_dev = devintr()) != 0){
    800026ec:	00000097          	auipc	ra,0x0
    800026f0:	ed2080e7          	jalr	-302(ra) # 800025be <devintr>
    800026f4:	892a                	mv	s2,a0
    800026f6:	c501                	beqz	a0,800026fe <usertrap+0xae>
  if(p->killed)
    800026f8:	589c                	lw	a5,48(s1)
    800026fa:	cf9d                	beqz	a5,80002738 <usertrap+0xe8>
    800026fc:	a815                	j	80002730 <usertrap+0xe0>
  asm volatile("csrr %0, scause" : "=r" (x) );
    800026fe:	142025f3          	csrr	a1,scause
    printf("usertrap(): unexpected scause %p pid=%d\n", r_scause(), p->pid);
    80002702:	58d0                	lw	a2,52(s1)
    80002704:	00005517          	auipc	a0,0x5
    80002708:	cc450513          	addi	a0,a0,-828 # 800073c8 <userret+0x338>
    8000270c:	ffffe097          	auipc	ra,0xffffe
    80002710:	ebc080e7          	jalr	-324(ra) # 800005c8 <printf>
  asm volatile("csrr %0, sepc" : "=r" (x) );
    80002714:	141025f3          	csrr	a1,sepc
  asm volatile("csrr %0, stval" : "=r" (x) );
    80002718:	14302673          	csrr	a2,stval
    printf("            sepc=%p stval=%p\n", r_sepc(), r_stval());
    8000271c:	00005517          	auipc	a0,0x5
    80002720:	cdc50513          	addi	a0,a0,-804 # 800073f8 <userret+0x368>
    80002724:	ffffe097          	auipc	ra,0xffffe
    80002728:	ea4080e7          	jalr	-348(ra) # 800005c8 <printf>
    p->killed = 1;
    8000272c:	4785                	li	a5,1
    8000272e:	d89c                	sw	a5,48(s1)
    exit();
    80002730:	00000097          	auipc	ra,0x0
    80002734:	860080e7          	jalr	-1952(ra) # 80001f90 <exit>
  if(which_dev == 2)
    80002738:	4789                	li	a5,2
    8000273a:	f8f912e3          	bne	s2,a5,800026be <usertrap+0x6e>
    yield();
    8000273e:	00000097          	auipc	ra,0x0
    80002742:	932080e7          	jalr	-1742(ra) # 80002070 <yield>
    80002746:	bfa5                	j	800026be <usertrap+0x6e>
  int which_dev = 0;
    80002748:	4901                	li	s2,0
    8000274a:	b7dd                	j	80002730 <usertrap+0xe0>

000000008000274c <kerneltrap>:
{
    8000274c:	7179                	addi	sp,sp,-48
    8000274e:	f406                	sd	ra,40(sp)
    80002750:	f022                	sd	s0,32(sp)
    80002752:	ec26                	sd	s1,24(sp)
    80002754:	e84a                	sd	s2,16(sp)
    80002756:	e44e                	sd	s3,8(sp)
    80002758:	1800                	addi	s0,sp,48
  asm volatile("csrr %0, sepc" : "=r" (x) );
    8000275a:	14102973          	csrr	s2,sepc
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    8000275e:	100024f3          	csrr	s1,sstatus
  asm volatile("csrr %0, scause" : "=r" (x) );
    80002762:	142029f3          	csrr	s3,scause
  if((sstatus & SSTATUS_SPP) == 0)
    80002766:	1004f793          	andi	a5,s1,256
    8000276a:	cb85                	beqz	a5,8000279a <kerneltrap+0x4e>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    8000276c:	100027f3          	csrr	a5,sstatus
  return (x & SSTATUS_SIE) != 0;
    80002770:	8b89                	andi	a5,a5,2
  if(intr_get() != 0)
    80002772:	ef85                	bnez	a5,800027aa <kerneltrap+0x5e>
  if((which_dev = devintr()) == 0){
    80002774:	00000097          	auipc	ra,0x0
    80002778:	e4a080e7          	jalr	-438(ra) # 800025be <devintr>
    8000277c:	cd1d                	beqz	a0,800027ba <kerneltrap+0x6e>
  if(which_dev == 2 && myproc() != 0 && myproc()->state == RUNNING)
    8000277e:	4789                	li	a5,2
    80002780:	06f50a63          	beq	a0,a5,800027f4 <kerneltrap+0xa8>
  asm volatile("csrw sepc, %0" : : "r" (x));
    80002784:	14191073          	csrw	sepc,s2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80002788:	10049073          	csrw	sstatus,s1
}
    8000278c:	70a2                	ld	ra,40(sp)
    8000278e:	7402                	ld	s0,32(sp)
    80002790:	64e2                	ld	s1,24(sp)
    80002792:	6942                	ld	s2,16(sp)
    80002794:	69a2                	ld	s3,8(sp)
    80002796:	6145                	addi	sp,sp,48
    80002798:	8082                	ret
    panic("kerneltrap: not from supervisor mode");
    8000279a:	00005517          	auipc	a0,0x5
    8000279e:	c7e50513          	addi	a0,a0,-898 # 80007418 <userret+0x388>
    800027a2:	ffffe097          	auipc	ra,0xffffe
    800027a6:	ddc080e7          	jalr	-548(ra) # 8000057e <panic>
    panic("kerneltrap: interrupts enabled");
    800027aa:	00005517          	auipc	a0,0x5
    800027ae:	c9650513          	addi	a0,a0,-874 # 80007440 <userret+0x3b0>
    800027b2:	ffffe097          	auipc	ra,0xffffe
    800027b6:	dcc080e7          	jalr	-564(ra) # 8000057e <panic>
    printf("scause %p\n", scause);
    800027ba:	85ce                	mv	a1,s3
    800027bc:	00005517          	auipc	a0,0x5
    800027c0:	ca450513          	addi	a0,a0,-860 # 80007460 <userret+0x3d0>
    800027c4:	ffffe097          	auipc	ra,0xffffe
    800027c8:	e04080e7          	jalr	-508(ra) # 800005c8 <printf>
  asm volatile("csrr %0, sepc" : "=r" (x) );
    800027cc:	141025f3          	csrr	a1,sepc
  asm volatile("csrr %0, stval" : "=r" (x) );
    800027d0:	14302673          	csrr	a2,stval
    printf("sepc=%p stval=%p\n", r_sepc(), r_stval());
    800027d4:	00005517          	auipc	a0,0x5
    800027d8:	c9c50513          	addi	a0,a0,-868 # 80007470 <userret+0x3e0>
    800027dc:	ffffe097          	auipc	ra,0xffffe
    800027e0:	dec080e7          	jalr	-532(ra) # 800005c8 <printf>
    panic("kerneltrap");
    800027e4:	00005517          	auipc	a0,0x5
    800027e8:	ca450513          	addi	a0,a0,-860 # 80007488 <userret+0x3f8>
    800027ec:	ffffe097          	auipc	ra,0xffffe
    800027f0:	d92080e7          	jalr	-622(ra) # 8000057e <panic>
  if(which_dev == 2 && myproc() != 0 && myproc()->state == RUNNING)
    800027f4:	fffff097          	auipc	ra,0xfffff
    800027f8:	0aa080e7          	jalr	170(ra) # 8000189e <myproc>
    800027fc:	d541                	beqz	a0,80002784 <kerneltrap+0x38>
    800027fe:	fffff097          	auipc	ra,0xfffff
    80002802:	0a0080e7          	jalr	160(ra) # 8000189e <myproc>
    80002806:	4d18                	lw	a4,24(a0)
    80002808:	478d                	li	a5,3
    8000280a:	f6f71de3          	bne	a4,a5,80002784 <kerneltrap+0x38>
    yield();
    8000280e:	00000097          	auipc	ra,0x0
    80002812:	862080e7          	jalr	-1950(ra) # 80002070 <yield>
    80002816:	b7bd                	j	80002784 <kerneltrap+0x38>

0000000080002818 <argraw>:
  return strlen(buf);
}

static uint64
argraw(int n)
{
    80002818:	1101                	addi	sp,sp,-32
    8000281a:	ec06                	sd	ra,24(sp)
    8000281c:	e822                	sd	s0,16(sp)
    8000281e:	e426                	sd	s1,8(sp)
    80002820:	1000                	addi	s0,sp,32
    80002822:	84aa                	mv	s1,a0
  struct proc *p = myproc();
    80002824:	fffff097          	auipc	ra,0xfffff
    80002828:	07a080e7          	jalr	122(ra) # 8000189e <myproc>
  switch (n) {
    8000282c:	4795                	li	a5,5
    8000282e:	0497e363          	bltu	a5,s1,80002874 <argraw+0x5c>
    80002832:	1482                	slli	s1,s1,0x20
    80002834:	9081                	srli	s1,s1,0x20
    80002836:	048a                	slli	s1,s1,0x2
    80002838:	00005717          	auipc	a4,0x5
    8000283c:	0d870713          	addi	a4,a4,216 # 80007910 <states.1779+0x28>
    80002840:	94ba                	add	s1,s1,a4
    80002842:	409c                	lw	a5,0(s1)
    80002844:	97ba                	add	a5,a5,a4
    80002846:	8782                	jr	a5
  case 0:
    return p->tf->a0;
    80002848:	693c                	ld	a5,80(a0)
    8000284a:	7ba8                	ld	a0,112(a5)
  case 5:
    return p->tf->a5;
  }
  panic("argraw");
  return -1;
}
    8000284c:	60e2                	ld	ra,24(sp)
    8000284e:	6442                	ld	s0,16(sp)
    80002850:	64a2                	ld	s1,8(sp)
    80002852:	6105                	addi	sp,sp,32
    80002854:	8082                	ret
    return p->tf->a1;
    80002856:	693c                	ld	a5,80(a0)
    80002858:	7fa8                	ld	a0,120(a5)
    8000285a:	bfcd                	j	8000284c <argraw+0x34>
    return p->tf->a2;
    8000285c:	693c                	ld	a5,80(a0)
    8000285e:	63c8                	ld	a0,128(a5)
    80002860:	b7f5                	j	8000284c <argraw+0x34>
    return p->tf->a3;
    80002862:	693c                	ld	a5,80(a0)
    80002864:	67c8                	ld	a0,136(a5)
    80002866:	b7dd                	j	8000284c <argraw+0x34>
    return p->tf->a4;
    80002868:	693c                	ld	a5,80(a0)
    8000286a:	6bc8                	ld	a0,144(a5)
    8000286c:	b7c5                	j	8000284c <argraw+0x34>
    return p->tf->a5;
    8000286e:	693c                	ld	a5,80(a0)
    80002870:	6fc8                	ld	a0,152(a5)
    80002872:	bfe9                	j	8000284c <argraw+0x34>
  panic("argraw");
    80002874:	00005517          	auipc	a0,0x5
    80002878:	c2450513          	addi	a0,a0,-988 # 80007498 <userret+0x408>
    8000287c:	ffffe097          	auipc	ra,0xffffe
    80002880:	d02080e7          	jalr	-766(ra) # 8000057e <panic>

0000000080002884 <fetchaddr>:
{
    80002884:	1101                	addi	sp,sp,-32
    80002886:	ec06                	sd	ra,24(sp)
    80002888:	e822                	sd	s0,16(sp)
    8000288a:	e426                	sd	s1,8(sp)
    8000288c:	e04a                	sd	s2,0(sp)
    8000288e:	1000                	addi	s0,sp,32
    80002890:	84aa                	mv	s1,a0
    80002892:	892e                	mv	s2,a1
  struct proc *p = myproc();
    80002894:	fffff097          	auipc	ra,0xfffff
    80002898:	00a080e7          	jalr	10(ra) # 8000189e <myproc>
  if(addr >= p->sz || addr+sizeof(uint64) > p->sz)
    8000289c:	613c                	ld	a5,64(a0)
    8000289e:	02f4f963          	bleu	a5,s1,800028d0 <fetchaddr+0x4c>
    800028a2:	00848713          	addi	a4,s1,8
    800028a6:	02e7e763          	bltu	a5,a4,800028d4 <fetchaddr+0x50>
  if(copyin(p->pagetable, (char *)ip, addr, sizeof(*ip)) != 0)
    800028aa:	46a1                	li	a3,8
    800028ac:	8626                	mv	a2,s1
    800028ae:	85ca                	mv	a1,s2
    800028b0:	6528                	ld	a0,72(a0)
    800028b2:	fffff097          	auipc	ra,0xfffff
    800028b6:	d8c080e7          	jalr	-628(ra) # 8000163e <copyin>
    800028ba:	00a03533          	snez	a0,a0
    800028be:	40a0053b          	negw	a0,a0
    800028c2:	2501                	sext.w	a0,a0
}
    800028c4:	60e2                	ld	ra,24(sp)
    800028c6:	6442                	ld	s0,16(sp)
    800028c8:	64a2                	ld	s1,8(sp)
    800028ca:	6902                	ld	s2,0(sp)
    800028cc:	6105                	addi	sp,sp,32
    800028ce:	8082                	ret
    return -1;
    800028d0:	557d                	li	a0,-1
    800028d2:	bfcd                	j	800028c4 <fetchaddr+0x40>
    800028d4:	557d                	li	a0,-1
    800028d6:	b7fd                	j	800028c4 <fetchaddr+0x40>

00000000800028d8 <fetchstr>:
{
    800028d8:	7179                	addi	sp,sp,-48
    800028da:	f406                	sd	ra,40(sp)
    800028dc:	f022                	sd	s0,32(sp)
    800028de:	ec26                	sd	s1,24(sp)
    800028e0:	e84a                	sd	s2,16(sp)
    800028e2:	e44e                	sd	s3,8(sp)
    800028e4:	1800                	addi	s0,sp,48
    800028e6:	892a                	mv	s2,a0
    800028e8:	84ae                	mv	s1,a1
    800028ea:	89b2                	mv	s3,a2
  struct proc *p = myproc();
    800028ec:	fffff097          	auipc	ra,0xfffff
    800028f0:	fb2080e7          	jalr	-78(ra) # 8000189e <myproc>
  int err = copyinstr(p->pagetable, buf, addr, max);
    800028f4:	86ce                	mv	a3,s3
    800028f6:	864a                	mv	a2,s2
    800028f8:	85a6                	mv	a1,s1
    800028fa:	6528                	ld	a0,72(a0)
    800028fc:	fffff097          	auipc	ra,0xfffff
    80002900:	dd6080e7          	jalr	-554(ra) # 800016d2 <copyinstr>
  if(err < 0)
    80002904:	00054763          	bltz	a0,80002912 <fetchstr+0x3a>
  return strlen(buf);
    80002908:	8526                	mv	a0,s1
    8000290a:	ffffe097          	auipc	ra,0xffffe
    8000290e:	466080e7          	jalr	1126(ra) # 80000d70 <strlen>
}
    80002912:	70a2                	ld	ra,40(sp)
    80002914:	7402                	ld	s0,32(sp)
    80002916:	64e2                	ld	s1,24(sp)
    80002918:	6942                	ld	s2,16(sp)
    8000291a:	69a2                	ld	s3,8(sp)
    8000291c:	6145                	addi	sp,sp,48
    8000291e:	8082                	ret

0000000080002920 <argint>:

// Fetch the nth 32-bit system call argument.
int
argint(int n, int *ip)
{
    80002920:	1101                	addi	sp,sp,-32
    80002922:	ec06                	sd	ra,24(sp)
    80002924:	e822                	sd	s0,16(sp)
    80002926:	e426                	sd	s1,8(sp)
    80002928:	1000                	addi	s0,sp,32
    8000292a:	84ae                	mv	s1,a1
  *ip = argraw(n);
    8000292c:	00000097          	auipc	ra,0x0
    80002930:	eec080e7          	jalr	-276(ra) # 80002818 <argraw>
    80002934:	c088                	sw	a0,0(s1)
  return 0;
}
    80002936:	4501                	li	a0,0
    80002938:	60e2                	ld	ra,24(sp)
    8000293a:	6442                	ld	s0,16(sp)
    8000293c:	64a2                	ld	s1,8(sp)
    8000293e:	6105                	addi	sp,sp,32
    80002940:	8082                	ret

0000000080002942 <argaddr>:
// Retrieve an argument as a pointer.
// Doesn't check for legality, since
// copyin/copyout will do that.
int
argaddr(int n, uint64 *ip)
{
    80002942:	1101                	addi	sp,sp,-32
    80002944:	ec06                	sd	ra,24(sp)
    80002946:	e822                	sd	s0,16(sp)
    80002948:	e426                	sd	s1,8(sp)
    8000294a:	1000                	addi	s0,sp,32
    8000294c:	84ae                	mv	s1,a1
  *ip = argraw(n);
    8000294e:	00000097          	auipc	ra,0x0
    80002952:	eca080e7          	jalr	-310(ra) # 80002818 <argraw>
    80002956:	e088                	sd	a0,0(s1)
  return 0;
}
    80002958:	4501                	li	a0,0
    8000295a:	60e2                	ld	ra,24(sp)
    8000295c:	6442                	ld	s0,16(sp)
    8000295e:	64a2                	ld	s1,8(sp)
    80002960:	6105                	addi	sp,sp,32
    80002962:	8082                	ret

0000000080002964 <argstr>:
// Fetch the nth word-sized system call argument as a null-terminated string.
// Copies into buf, at most max.
// Returns string length if OK (including nul), -1 if error.
int
argstr(int n, char *buf, int max)
{
    80002964:	1101                	addi	sp,sp,-32
    80002966:	ec06                	sd	ra,24(sp)
    80002968:	e822                	sd	s0,16(sp)
    8000296a:	e426                	sd	s1,8(sp)
    8000296c:	e04a                	sd	s2,0(sp)
    8000296e:	1000                	addi	s0,sp,32
    80002970:	84ae                	mv	s1,a1
    80002972:	8932                	mv	s2,a2
  *ip = argraw(n);
    80002974:	00000097          	auipc	ra,0x0
    80002978:	ea4080e7          	jalr	-348(ra) # 80002818 <argraw>
  uint64 addr;
  if(argaddr(n, &addr) < 0)
    return -1;
  return fetchstr(addr, buf, max);
    8000297c:	864a                	mv	a2,s2
    8000297e:	85a6                	mv	a1,s1
    80002980:	00000097          	auipc	ra,0x0
    80002984:	f58080e7          	jalr	-168(ra) # 800028d8 <fetchstr>
}
    80002988:	60e2                	ld	ra,24(sp)
    8000298a:	6442                	ld	s0,16(sp)
    8000298c:	64a2                	ld	s1,8(sp)
    8000298e:	6902                	ld	s2,0(sp)
    80002990:	6105                	addi	sp,sp,32
    80002992:	8082                	ret

0000000080002994 <syscall>:
[SYS_hello]   sys_hello,
};

void
syscall(void)
{
    80002994:	1101                	addi	sp,sp,-32
    80002996:	ec06                	sd	ra,24(sp)
    80002998:	e822                	sd	s0,16(sp)
    8000299a:	e426                	sd	s1,8(sp)
    8000299c:	e04a                	sd	s2,0(sp)
    8000299e:	1000                	addi	s0,sp,32
  int num;
  struct proc *p = myproc();
    800029a0:	fffff097          	auipc	ra,0xfffff
    800029a4:	efe080e7          	jalr	-258(ra) # 8000189e <myproc>
    800029a8:	84aa                	mv	s1,a0

  num = p->tf->a7;
    800029aa:	05053903          	ld	s2,80(a0)
    800029ae:	0a893783          	ld	a5,168(s2)
    800029b2:	0007869b          	sext.w	a3,a5
  if(num > 0 && num < NELEM(syscalls) && syscalls[num]) {
    800029b6:	37fd                	addiw	a5,a5,-1
    800029b8:	4765                	li	a4,25
    800029ba:	00f76f63          	bltu	a4,a5,800029d8 <syscall+0x44>
    800029be:	00369713          	slli	a4,a3,0x3
    800029c2:	00005797          	auipc	a5,0x5
    800029c6:	f6678793          	addi	a5,a5,-154 # 80007928 <syscalls>
    800029ca:	97ba                	add	a5,a5,a4
    800029cc:	639c                	ld	a5,0(a5)
    800029ce:	c789                	beqz	a5,800029d8 <syscall+0x44>
    p->tf->a0 = syscalls[num]();
    800029d0:	9782                	jalr	a5
    800029d2:	06a93823          	sd	a0,112(s2)
    800029d6:	a839                	j	800029f4 <syscall+0x60>
  } else {
    printf("%d %s: unknown sys call %d\n",
    800029d8:	15048613          	addi	a2,s1,336
    800029dc:	58cc                	lw	a1,52(s1)
    800029de:	00005517          	auipc	a0,0x5
    800029e2:	ac250513          	addi	a0,a0,-1342 # 800074a0 <userret+0x410>
    800029e6:	ffffe097          	auipc	ra,0xffffe
    800029ea:	be2080e7          	jalr	-1054(ra) # 800005c8 <printf>
            p->pid, p->name, num);
    p->tf->a0 = -1;
    800029ee:	68bc                	ld	a5,80(s1)
    800029f0:	577d                	li	a4,-1
    800029f2:	fbb8                	sd	a4,112(a5)
  }
}
    800029f4:	60e2                	ld	ra,24(sp)
    800029f6:	6442                	ld	s0,16(sp)
    800029f8:	64a2                	ld	s1,8(sp)
    800029fa:	6902                	ld	s2,0(sp)
    800029fc:	6105                	addi	sp,sp,32
    800029fe:	8082                	ret

0000000080002a00 <sys_exit>:
#include "spinlock.h"
#include "proc.h"

uint64
sys_exit(void)
{
    80002a00:	1141                	addi	sp,sp,-16
    80002a02:	e406                	sd	ra,8(sp)
    80002a04:	e022                	sd	s0,0(sp)
    80002a06:	0800                	addi	s0,sp,16
  exit();
    80002a08:	fffff097          	auipc	ra,0xfffff
    80002a0c:	588080e7          	jalr	1416(ra) # 80001f90 <exit>
  return 0;  // not reached
}
    80002a10:	4501                	li	a0,0
    80002a12:	60a2                	ld	ra,8(sp)
    80002a14:	6402                	ld	s0,0(sp)
    80002a16:	0141                	addi	sp,sp,16
    80002a18:	8082                	ret

0000000080002a1a <sys_getpid>:

uint64
sys_getpid(void)
{
    80002a1a:	1141                	addi	sp,sp,-16
    80002a1c:	e406                	sd	ra,8(sp)
    80002a1e:	e022                	sd	s0,0(sp)
    80002a20:	0800                	addi	s0,sp,16
  return myproc()->pid;
    80002a22:	fffff097          	auipc	ra,0xfffff
    80002a26:	e7c080e7          	jalr	-388(ra) # 8000189e <myproc>
}
    80002a2a:	5948                	lw	a0,52(a0)
    80002a2c:	60a2                	ld	ra,8(sp)
    80002a2e:	6402                	ld	s0,0(sp)
    80002a30:	0141                	addi	sp,sp,16
    80002a32:	8082                	ret

0000000080002a34 <sys_fork>:

uint64
sys_fork(void)
{
    80002a34:	1141                	addi	sp,sp,-16
    80002a36:	e406                	sd	ra,8(sp)
    80002a38:	e022                	sd	s0,0(sp)
    80002a3a:	0800                	addi	s0,sp,16
  return fork();
    80002a3c:	fffff097          	auipc	ra,0xfffff
    80002a40:	1d2080e7          	jalr	466(ra) # 80001c0e <fork>
}
    80002a44:	60a2                	ld	ra,8(sp)
    80002a46:	6402                	ld	s0,0(sp)
    80002a48:	0141                	addi	sp,sp,16
    80002a4a:	8082                	ret

0000000080002a4c <sys_wait>:

uint64
sys_wait(void)
{
    80002a4c:	1141                	addi	sp,sp,-16
    80002a4e:	e406                	sd	ra,8(sp)
    80002a50:	e022                	sd	s0,0(sp)
    80002a52:	0800                	addi	s0,sp,16
  return wait();
    80002a54:	fffff097          	auipc	ra,0xfffff
    80002a58:	6d6080e7          	jalr	1750(ra) # 8000212a <wait>
}
    80002a5c:	60a2                	ld	ra,8(sp)
    80002a5e:	6402                	ld	s0,0(sp)
    80002a60:	0141                	addi	sp,sp,16
    80002a62:	8082                	ret

0000000080002a64 <sys_sbrk>:

uint64
sys_sbrk(void)
{
    80002a64:	7179                	addi	sp,sp,-48
    80002a66:	f406                	sd	ra,40(sp)
    80002a68:	f022                	sd	s0,32(sp)
    80002a6a:	ec26                	sd	s1,24(sp)
    80002a6c:	1800                	addi	s0,sp,48
  int addr;
  int n;

  if(argint(0, &n) < 0)
    80002a6e:	fdc40593          	addi	a1,s0,-36
    80002a72:	4501                	li	a0,0
    80002a74:	00000097          	auipc	ra,0x0
    80002a78:	eac080e7          	jalr	-340(ra) # 80002920 <argint>
    return -1;
    80002a7c:	54fd                	li	s1,-1
  if(argint(0, &n) < 0)
    80002a7e:	00054f63          	bltz	a0,80002a9c <sys_sbrk+0x38>
  addr = myproc()->sz;
    80002a82:	fffff097          	auipc	ra,0xfffff
    80002a86:	e1c080e7          	jalr	-484(ra) # 8000189e <myproc>
    80002a8a:	4124                	lw	s1,64(a0)
  if(growproc(n) < 0)
    80002a8c:	fdc42503          	lw	a0,-36(s0)
    80002a90:	fffff097          	auipc	ra,0xfffff
    80002a94:	102080e7          	jalr	258(ra) # 80001b92 <growproc>
    80002a98:	00054863          	bltz	a0,80002aa8 <sys_sbrk+0x44>
    return -1;
  return addr;
}
    80002a9c:	8526                	mv	a0,s1
    80002a9e:	70a2                	ld	ra,40(sp)
    80002aa0:	7402                	ld	s0,32(sp)
    80002aa2:	64e2                	ld	s1,24(sp)
    80002aa4:	6145                	addi	sp,sp,48
    80002aa6:	8082                	ret
    return -1;
    80002aa8:	54fd                	li	s1,-1
    80002aaa:	bfcd                	j	80002a9c <sys_sbrk+0x38>

0000000080002aac <sys_sleep>:

uint64
sys_sleep(void)
{
    80002aac:	7139                	addi	sp,sp,-64
    80002aae:	fc06                	sd	ra,56(sp)
    80002ab0:	f822                	sd	s0,48(sp)
    80002ab2:	f426                	sd	s1,40(sp)
    80002ab4:	f04a                	sd	s2,32(sp)
    80002ab6:	ec4e                	sd	s3,24(sp)
    80002ab8:	0080                	addi	s0,sp,64
  int n;
  uint ticks0;

  if(argint(0, &n) < 0)
    80002aba:	fcc40593          	addi	a1,s0,-52
    80002abe:	4501                	li	a0,0
    80002ac0:	00000097          	auipc	ra,0x0
    80002ac4:	e60080e7          	jalr	-416(ra) # 80002920 <argint>
    return -1;
    80002ac8:	57fd                	li	a5,-1
  if(argint(0, &n) < 0)
    80002aca:	06054763          	bltz	a0,80002b38 <sys_sleep+0x8c>
  acquire(&tickslock);
    80002ace:	00015517          	auipc	a0,0x15
    80002ad2:	a3250513          	addi	a0,a0,-1486 # 80017500 <tickslock>
    80002ad6:	ffffe097          	auipc	ra,0xffffe
    80002ada:	02a080e7          	jalr	42(ra) # 80000b00 <acquire>
  ticks0 = ticks;
    80002ade:	00026797          	auipc	a5,0x26
    80002ae2:	54a78793          	addi	a5,a5,1354 # 80029028 <ticks>
    80002ae6:	0007a903          	lw	s2,0(a5)
  while(ticks - ticks0 < n){
    80002aea:	fcc42783          	lw	a5,-52(s0)
    80002aee:	cf85                	beqz	a5,80002b26 <sys_sleep+0x7a>
    if(myproc()->killed){
      release(&tickslock);
      return -1;
    }
    sleep(&ticks, &tickslock);
    80002af0:	00015997          	auipc	s3,0x15
    80002af4:	a1098993          	addi	s3,s3,-1520 # 80017500 <tickslock>
    80002af8:	00026497          	auipc	s1,0x26
    80002afc:	53048493          	addi	s1,s1,1328 # 80029028 <ticks>
    if(myproc()->killed){
    80002b00:	fffff097          	auipc	ra,0xfffff
    80002b04:	d9e080e7          	jalr	-610(ra) # 8000189e <myproc>
    80002b08:	591c                	lw	a5,48(a0)
    80002b0a:	ef9d                	bnez	a5,80002b48 <sys_sleep+0x9c>
    sleep(&ticks, &tickslock);
    80002b0c:	85ce                	mv	a1,s3
    80002b0e:	8526                	mv	a0,s1
    80002b10:	fffff097          	auipc	ra,0xfffff
    80002b14:	59c080e7          	jalr	1436(ra) # 800020ac <sleep>
  while(ticks - ticks0 < n){
    80002b18:	409c                	lw	a5,0(s1)
    80002b1a:	412787bb          	subw	a5,a5,s2
    80002b1e:	fcc42703          	lw	a4,-52(s0)
    80002b22:	fce7efe3          	bltu	a5,a4,80002b00 <sys_sleep+0x54>
  }
  release(&tickslock);
    80002b26:	00015517          	auipc	a0,0x15
    80002b2a:	9da50513          	addi	a0,a0,-1574 # 80017500 <tickslock>
    80002b2e:	ffffe097          	auipc	ra,0xffffe
    80002b32:	03a080e7          	jalr	58(ra) # 80000b68 <release>
  return 0;
    80002b36:	4781                	li	a5,0
}
    80002b38:	853e                	mv	a0,a5
    80002b3a:	70e2                	ld	ra,56(sp)
    80002b3c:	7442                	ld	s0,48(sp)
    80002b3e:	74a2                	ld	s1,40(sp)
    80002b40:	7902                	ld	s2,32(sp)
    80002b42:	69e2                	ld	s3,24(sp)
    80002b44:	6121                	addi	sp,sp,64
    80002b46:	8082                	ret
      release(&tickslock);
    80002b48:	00015517          	auipc	a0,0x15
    80002b4c:	9b850513          	addi	a0,a0,-1608 # 80017500 <tickslock>
    80002b50:	ffffe097          	auipc	ra,0xffffe
    80002b54:	018080e7          	jalr	24(ra) # 80000b68 <release>
      return -1;
    80002b58:	57fd                	li	a5,-1
    80002b5a:	bff9                	j	80002b38 <sys_sleep+0x8c>

0000000080002b5c <sys_kill>:

uint64
sys_kill(void)
{
    80002b5c:	1101                	addi	sp,sp,-32
    80002b5e:	ec06                	sd	ra,24(sp)
    80002b60:	e822                	sd	s0,16(sp)
    80002b62:	1000                	addi	s0,sp,32
  int pid;

  if(argint(0, &pid) < 0)
    80002b64:	fec40593          	addi	a1,s0,-20
    80002b68:	4501                	li	a0,0
    80002b6a:	00000097          	auipc	ra,0x0
    80002b6e:	db6080e7          	jalr	-586(ra) # 80002920 <argint>
    return -1;
    80002b72:	57fd                	li	a5,-1
  if(argint(0, &pid) < 0)
    80002b74:	00054963          	bltz	a0,80002b86 <sys_kill+0x2a>
  return kill(pid);
    80002b78:	fec42503          	lw	a0,-20(s0)
    80002b7c:	fffff097          	auipc	ra,0xfffff
    80002b80:	6e6080e7          	jalr	1766(ra) # 80002262 <kill>
    80002b84:	87aa                	mv	a5,a0
}
    80002b86:	853e                	mv	a0,a5
    80002b88:	60e2                	ld	ra,24(sp)
    80002b8a:	6442                	ld	s0,16(sp)
    80002b8c:	6105                	addi	sp,sp,32
    80002b8e:	8082                	ret

0000000080002b90 <sys_uptime>:

// return how many clock tick interrupts have occurred
// since start.
uint64
sys_uptime(void)
{
    80002b90:	1101                	addi	sp,sp,-32
    80002b92:	ec06                	sd	ra,24(sp)
    80002b94:	e822                	sd	s0,16(sp)
    80002b96:	e426                	sd	s1,8(sp)
    80002b98:	1000                	addi	s0,sp,32
  uint xticks;

  acquire(&tickslock);
    80002b9a:	00015517          	auipc	a0,0x15
    80002b9e:	96650513          	addi	a0,a0,-1690 # 80017500 <tickslock>
    80002ba2:	ffffe097          	auipc	ra,0xffffe
    80002ba6:	f5e080e7          	jalr	-162(ra) # 80000b00 <acquire>
  xticks = ticks;
    80002baa:	00026797          	auipc	a5,0x26
    80002bae:	47e78793          	addi	a5,a5,1150 # 80029028 <ticks>
    80002bb2:	4384                	lw	s1,0(a5)
  release(&tickslock);
    80002bb4:	00015517          	auipc	a0,0x15
    80002bb8:	94c50513          	addi	a0,a0,-1716 # 80017500 <tickslock>
    80002bbc:	ffffe097          	auipc	ra,0xffffe
    80002bc0:	fac080e7          	jalr	-84(ra) # 80000b68 <release>
  return xticks;
}
    80002bc4:	02049513          	slli	a0,s1,0x20
    80002bc8:	9101                	srli	a0,a0,0x20
    80002bca:	60e2                	ld	ra,24(sp)
    80002bcc:	6442                	ld	s0,16(sp)
    80002bce:	64a2                	ld	s1,8(sp)
    80002bd0:	6105                	addi	sp,sp,32
    80002bd2:	8082                	ret

0000000080002bd4 <sys_hello>:

uint64
sys_hello(void) {
    80002bd4:	1141                	addi	sp,sp,-16
    80002bd6:	e406                	sd	ra,8(sp)
    80002bd8:	e022                	sd	s0,0(sp)
    80002bda:	0800                	addi	s0,sp,16
  printf("Hello syscall from xv6!\n");
    80002bdc:	00005517          	auipc	a0,0x5
    80002be0:	8e450513          	addi	a0,a0,-1820 # 800074c0 <userret+0x430>
    80002be4:	ffffe097          	auipc	ra,0xffffe
    80002be8:	9e4080e7          	jalr	-1564(ra) # 800005c8 <printf>
  return 0;
    80002bec:	4501                	li	a0,0
    80002bee:	60a2                	ld	ra,8(sp)
    80002bf0:	6402                	ld	s0,0(sp)
    80002bf2:	0141                	addi	sp,sp,16
    80002bf4:	8082                	ret

0000000080002bf6 <binit>:
  struct buf head;
} bcache;

void
binit(void)
{
    80002bf6:	7179                	addi	sp,sp,-48
    80002bf8:	f406                	sd	ra,40(sp)
    80002bfa:	f022                	sd	s0,32(sp)
    80002bfc:	ec26                	sd	s1,24(sp)
    80002bfe:	e84a                	sd	s2,16(sp)
    80002c00:	e44e                	sd	s3,8(sp)
    80002c02:	e052                	sd	s4,0(sp)
    80002c04:	1800                	addi	s0,sp,48
  struct buf *b;

  initlock(&bcache.lock, "bcache");
    80002c06:	00005597          	auipc	a1,0x5
    80002c0a:	8da58593          	addi	a1,a1,-1830 # 800074e0 <userret+0x450>
    80002c0e:	00015517          	auipc	a0,0x15
    80002c12:	90a50513          	addi	a0,a0,-1782 # 80017518 <bcache>
    80002c16:	ffffe097          	auipc	ra,0xffffe
    80002c1a:	ddc080e7          	jalr	-548(ra) # 800009f2 <initlock>

  // Create linked list of buffers
  bcache.head.prev = &bcache.head;
    80002c1e:	0001d797          	auipc	a5,0x1d
    80002c22:	8fa78793          	addi	a5,a5,-1798 # 8001f518 <bcache+0x8000>
    80002c26:	0001d717          	auipc	a4,0x1d
    80002c2a:	c4a70713          	addi	a4,a4,-950 # 8001f870 <bcache+0x8358>
    80002c2e:	3ae7b023          	sd	a4,928(a5)
  bcache.head.next = &bcache.head;
    80002c32:	3ae7b423          	sd	a4,936(a5)
  for(b = bcache.buf; b < bcache.buf+NBUF; b++){
    80002c36:	00015497          	auipc	s1,0x15
    80002c3a:	8fa48493          	addi	s1,s1,-1798 # 80017530 <bcache+0x18>
    b->next = bcache.head.next;
    80002c3e:	893e                	mv	s2,a5
    b->prev = &bcache.head;
    80002c40:	89ba                	mv	s3,a4
    initsleeplock(&b->lock, "buffer");
    80002c42:	00005a17          	auipc	s4,0x5
    80002c46:	8a6a0a13          	addi	s4,s4,-1882 # 800074e8 <userret+0x458>
    b->next = bcache.head.next;
    80002c4a:	3a893783          	ld	a5,936(s2)
    80002c4e:	e8bc                	sd	a5,80(s1)
    b->prev = &bcache.head;
    80002c50:	0534b423          	sd	s3,72(s1)
    initsleeplock(&b->lock, "buffer");
    80002c54:	85d2                	mv	a1,s4
    80002c56:	01048513          	addi	a0,s1,16
    80002c5a:	00001097          	auipc	ra,0x1
    80002c5e:	75e080e7          	jalr	1886(ra) # 800043b8 <initsleeplock>
    bcache.head.next->prev = b;
    80002c62:	3a893783          	ld	a5,936(s2)
    80002c66:	e7a4                	sd	s1,72(a5)
    bcache.head.next = b;
    80002c68:	3a993423          	sd	s1,936(s2)
  for(b = bcache.buf; b < bcache.buf+NBUF; b++){
    80002c6c:	46048493          	addi	s1,s1,1120
    80002c70:	fd349de3          	bne	s1,s3,80002c4a <binit+0x54>
  }
}
    80002c74:	70a2                	ld	ra,40(sp)
    80002c76:	7402                	ld	s0,32(sp)
    80002c78:	64e2                	ld	s1,24(sp)
    80002c7a:	6942                	ld	s2,16(sp)
    80002c7c:	69a2                	ld	s3,8(sp)
    80002c7e:	6a02                	ld	s4,0(sp)
    80002c80:	6145                	addi	sp,sp,48
    80002c82:	8082                	ret

0000000080002c84 <bread>:
}

// Return a locked buf with the contents of the indicated block.
struct buf*
bread(uint dev, uint blockno)
{
    80002c84:	7179                	addi	sp,sp,-48
    80002c86:	f406                	sd	ra,40(sp)
    80002c88:	f022                	sd	s0,32(sp)
    80002c8a:	ec26                	sd	s1,24(sp)
    80002c8c:	e84a                	sd	s2,16(sp)
    80002c8e:	e44e                	sd	s3,8(sp)
    80002c90:	1800                	addi	s0,sp,48
    80002c92:	89aa                	mv	s3,a0
    80002c94:	892e                	mv	s2,a1
  acquire(&bcache.lock);
    80002c96:	00015517          	auipc	a0,0x15
    80002c9a:	88250513          	addi	a0,a0,-1918 # 80017518 <bcache>
    80002c9e:	ffffe097          	auipc	ra,0xffffe
    80002ca2:	e62080e7          	jalr	-414(ra) # 80000b00 <acquire>
  for(b = bcache.head.next; b != &bcache.head; b = b->next){
    80002ca6:	0001d797          	auipc	a5,0x1d
    80002caa:	87278793          	addi	a5,a5,-1934 # 8001f518 <bcache+0x8000>
    80002cae:	3a87b483          	ld	s1,936(a5)
    80002cb2:	0001d797          	auipc	a5,0x1d
    80002cb6:	bbe78793          	addi	a5,a5,-1090 # 8001f870 <bcache+0x8358>
    80002cba:	02f48f63          	beq	s1,a5,80002cf8 <bread+0x74>
    80002cbe:	873e                	mv	a4,a5
    80002cc0:	a021                	j	80002cc8 <bread+0x44>
    80002cc2:	68a4                	ld	s1,80(s1)
    80002cc4:	02e48a63          	beq	s1,a4,80002cf8 <bread+0x74>
    if(b->dev == dev && b->blockno == blockno){
    80002cc8:	449c                	lw	a5,8(s1)
    80002cca:	ff379ce3          	bne	a5,s3,80002cc2 <bread+0x3e>
    80002cce:	44dc                	lw	a5,12(s1)
    80002cd0:	ff2799e3          	bne	a5,s2,80002cc2 <bread+0x3e>
      b->refcnt++;
    80002cd4:	40bc                	lw	a5,64(s1)
    80002cd6:	2785                	addiw	a5,a5,1
    80002cd8:	c0bc                	sw	a5,64(s1)
      release(&bcache.lock);
    80002cda:	00015517          	auipc	a0,0x15
    80002cde:	83e50513          	addi	a0,a0,-1986 # 80017518 <bcache>
    80002ce2:	ffffe097          	auipc	ra,0xffffe
    80002ce6:	e86080e7          	jalr	-378(ra) # 80000b68 <release>
      acquiresleep(&b->lock);
    80002cea:	01048513          	addi	a0,s1,16
    80002cee:	00001097          	auipc	ra,0x1
    80002cf2:	704080e7          	jalr	1796(ra) # 800043f2 <acquiresleep>
      return b;
    80002cf6:	a8b1                	j	80002d52 <bread+0xce>
  for(b = bcache.head.prev; b != &bcache.head; b = b->prev){
    80002cf8:	0001d797          	auipc	a5,0x1d
    80002cfc:	82078793          	addi	a5,a5,-2016 # 8001f518 <bcache+0x8000>
    80002d00:	3a07b483          	ld	s1,928(a5)
    80002d04:	0001d797          	auipc	a5,0x1d
    80002d08:	b6c78793          	addi	a5,a5,-1172 # 8001f870 <bcache+0x8358>
    80002d0c:	04f48d63          	beq	s1,a5,80002d66 <bread+0xe2>
    if(b->refcnt == 0) {
    80002d10:	40bc                	lw	a5,64(s1)
    80002d12:	cb91                	beqz	a5,80002d26 <bread+0xa2>
  for(b = bcache.head.prev; b != &bcache.head; b = b->prev){
    80002d14:	0001d717          	auipc	a4,0x1d
    80002d18:	b5c70713          	addi	a4,a4,-1188 # 8001f870 <bcache+0x8358>
    80002d1c:	64a4                	ld	s1,72(s1)
    80002d1e:	04e48463          	beq	s1,a4,80002d66 <bread+0xe2>
    if(b->refcnt == 0) {
    80002d22:	40bc                	lw	a5,64(s1)
    80002d24:	ffe5                	bnez	a5,80002d1c <bread+0x98>
      b->dev = dev;
    80002d26:	0134a423          	sw	s3,8(s1)
      b->blockno = blockno;
    80002d2a:	0124a623          	sw	s2,12(s1)
      b->valid = 0;
    80002d2e:	0004a023          	sw	zero,0(s1)
      b->refcnt = 1;
    80002d32:	4785                	li	a5,1
    80002d34:	c0bc                	sw	a5,64(s1)
      release(&bcache.lock);
    80002d36:	00014517          	auipc	a0,0x14
    80002d3a:	7e250513          	addi	a0,a0,2018 # 80017518 <bcache>
    80002d3e:	ffffe097          	auipc	ra,0xffffe
    80002d42:	e2a080e7          	jalr	-470(ra) # 80000b68 <release>
      acquiresleep(&b->lock);
    80002d46:	01048513          	addi	a0,s1,16
    80002d4a:	00001097          	auipc	ra,0x1
    80002d4e:	6a8080e7          	jalr	1704(ra) # 800043f2 <acquiresleep>
  struct buf *b;

  b = bget(dev, blockno);
  if(!b->valid) {
    80002d52:	409c                	lw	a5,0(s1)
    80002d54:	c38d                	beqz	a5,80002d76 <bread+0xf2>
    virtio_disk_rw(b->dev, b, 0);
    b->valid = 1;
  }
  return b;
}
    80002d56:	8526                	mv	a0,s1
    80002d58:	70a2                	ld	ra,40(sp)
    80002d5a:	7402                	ld	s0,32(sp)
    80002d5c:	64e2                	ld	s1,24(sp)
    80002d5e:	6942                	ld	s2,16(sp)
    80002d60:	69a2                	ld	s3,8(sp)
    80002d62:	6145                	addi	sp,sp,48
    80002d64:	8082                	ret
  panic("bget: no buffers");
    80002d66:	00004517          	auipc	a0,0x4
    80002d6a:	78a50513          	addi	a0,a0,1930 # 800074f0 <userret+0x460>
    80002d6e:	ffffe097          	auipc	ra,0xffffe
    80002d72:	810080e7          	jalr	-2032(ra) # 8000057e <panic>
    virtio_disk_rw(b->dev, b, 0);
    80002d76:	4601                	li	a2,0
    80002d78:	85a6                	mv	a1,s1
    80002d7a:	4488                	lw	a0,8(s1)
    80002d7c:	00003097          	auipc	ra,0x3
    80002d80:	340080e7          	jalr	832(ra) # 800060bc <virtio_disk_rw>
    b->valid = 1;
    80002d84:	4785                	li	a5,1
    80002d86:	c09c                	sw	a5,0(s1)
  return b;
    80002d88:	b7f9                	j	80002d56 <bread+0xd2>

0000000080002d8a <bwrite>:

// Write b's contents to disk.  Must be locked.
void
bwrite(struct buf *b)
{
    80002d8a:	1101                	addi	sp,sp,-32
    80002d8c:	ec06                	sd	ra,24(sp)
    80002d8e:	e822                	sd	s0,16(sp)
    80002d90:	e426                	sd	s1,8(sp)
    80002d92:	1000                	addi	s0,sp,32
    80002d94:	84aa                	mv	s1,a0
  if(!holdingsleep(&b->lock))
    80002d96:	0541                	addi	a0,a0,16
    80002d98:	00001097          	auipc	ra,0x1
    80002d9c:	6f4080e7          	jalr	1780(ra) # 8000448c <holdingsleep>
    80002da0:	cd09                	beqz	a0,80002dba <bwrite+0x30>
    panic("bwrite");
  virtio_disk_rw(b->dev, b, 1);
    80002da2:	4605                	li	a2,1
    80002da4:	85a6                	mv	a1,s1
    80002da6:	4488                	lw	a0,8(s1)
    80002da8:	00003097          	auipc	ra,0x3
    80002dac:	314080e7          	jalr	788(ra) # 800060bc <virtio_disk_rw>
}
    80002db0:	60e2                	ld	ra,24(sp)
    80002db2:	6442                	ld	s0,16(sp)
    80002db4:	64a2                	ld	s1,8(sp)
    80002db6:	6105                	addi	sp,sp,32
    80002db8:	8082                	ret
    panic("bwrite");
    80002dba:	00004517          	auipc	a0,0x4
    80002dbe:	74e50513          	addi	a0,a0,1870 # 80007508 <userret+0x478>
    80002dc2:	ffffd097          	auipc	ra,0xffffd
    80002dc6:	7bc080e7          	jalr	1980(ra) # 8000057e <panic>

0000000080002dca <brelse>:

// Release a locked buffer.
// Move to the head of the MRU list.
void
brelse(struct buf *b)
{
    80002dca:	1101                	addi	sp,sp,-32
    80002dcc:	ec06                	sd	ra,24(sp)
    80002dce:	e822                	sd	s0,16(sp)
    80002dd0:	e426                	sd	s1,8(sp)
    80002dd2:	e04a                	sd	s2,0(sp)
    80002dd4:	1000                	addi	s0,sp,32
    80002dd6:	84aa                	mv	s1,a0
  if(!holdingsleep(&b->lock))
    80002dd8:	01050913          	addi	s2,a0,16
    80002ddc:	854a                	mv	a0,s2
    80002dde:	00001097          	auipc	ra,0x1
    80002de2:	6ae080e7          	jalr	1710(ra) # 8000448c <holdingsleep>
    80002de6:	c92d                	beqz	a0,80002e58 <brelse+0x8e>
    panic("brelse");

  releasesleep(&b->lock);
    80002de8:	854a                	mv	a0,s2
    80002dea:	00001097          	auipc	ra,0x1
    80002dee:	65e080e7          	jalr	1630(ra) # 80004448 <releasesleep>

  acquire(&bcache.lock);
    80002df2:	00014517          	auipc	a0,0x14
    80002df6:	72650513          	addi	a0,a0,1830 # 80017518 <bcache>
    80002dfa:	ffffe097          	auipc	ra,0xffffe
    80002dfe:	d06080e7          	jalr	-762(ra) # 80000b00 <acquire>
  b->refcnt--;
    80002e02:	40bc                	lw	a5,64(s1)
    80002e04:	37fd                	addiw	a5,a5,-1
    80002e06:	0007871b          	sext.w	a4,a5
    80002e0a:	c0bc                	sw	a5,64(s1)
  if (b->refcnt == 0) {
    80002e0c:	eb05                	bnez	a4,80002e3c <brelse+0x72>
    // no one is waiting for it.
    b->next->prev = b->prev;
    80002e0e:	68bc                	ld	a5,80(s1)
    80002e10:	64b8                	ld	a4,72(s1)
    80002e12:	e7b8                	sd	a4,72(a5)
    b->prev->next = b->next;
    80002e14:	64bc                	ld	a5,72(s1)
    80002e16:	68b8                	ld	a4,80(s1)
    80002e18:	ebb8                	sd	a4,80(a5)
    b->next = bcache.head.next;
    80002e1a:	0001c797          	auipc	a5,0x1c
    80002e1e:	6fe78793          	addi	a5,a5,1790 # 8001f518 <bcache+0x8000>
    80002e22:	3a87b703          	ld	a4,936(a5)
    80002e26:	e8b8                	sd	a4,80(s1)
    b->prev = &bcache.head;
    80002e28:	0001d717          	auipc	a4,0x1d
    80002e2c:	a4870713          	addi	a4,a4,-1464 # 8001f870 <bcache+0x8358>
    80002e30:	e4b8                	sd	a4,72(s1)
    bcache.head.next->prev = b;
    80002e32:	3a87b703          	ld	a4,936(a5)
    80002e36:	e724                	sd	s1,72(a4)
    bcache.head.next = b;
    80002e38:	3a97b423          	sd	s1,936(a5)
  }
  
  release(&bcache.lock);
    80002e3c:	00014517          	auipc	a0,0x14
    80002e40:	6dc50513          	addi	a0,a0,1756 # 80017518 <bcache>
    80002e44:	ffffe097          	auipc	ra,0xffffe
    80002e48:	d24080e7          	jalr	-732(ra) # 80000b68 <release>
}
    80002e4c:	60e2                	ld	ra,24(sp)
    80002e4e:	6442                	ld	s0,16(sp)
    80002e50:	64a2                	ld	s1,8(sp)
    80002e52:	6902                	ld	s2,0(sp)
    80002e54:	6105                	addi	sp,sp,32
    80002e56:	8082                	ret
    panic("brelse");
    80002e58:	00004517          	auipc	a0,0x4
    80002e5c:	6b850513          	addi	a0,a0,1720 # 80007510 <userret+0x480>
    80002e60:	ffffd097          	auipc	ra,0xffffd
    80002e64:	71e080e7          	jalr	1822(ra) # 8000057e <panic>

0000000080002e68 <bpin>:

void
bpin(struct buf *b) {
    80002e68:	1101                	addi	sp,sp,-32
    80002e6a:	ec06                	sd	ra,24(sp)
    80002e6c:	e822                	sd	s0,16(sp)
    80002e6e:	e426                	sd	s1,8(sp)
    80002e70:	1000                	addi	s0,sp,32
    80002e72:	84aa                	mv	s1,a0
  acquire(&bcache.lock);
    80002e74:	00014517          	auipc	a0,0x14
    80002e78:	6a450513          	addi	a0,a0,1700 # 80017518 <bcache>
    80002e7c:	ffffe097          	auipc	ra,0xffffe
    80002e80:	c84080e7          	jalr	-892(ra) # 80000b00 <acquire>
  b->refcnt++;
    80002e84:	40bc                	lw	a5,64(s1)
    80002e86:	2785                	addiw	a5,a5,1
    80002e88:	c0bc                	sw	a5,64(s1)
  release(&bcache.lock);
    80002e8a:	00014517          	auipc	a0,0x14
    80002e8e:	68e50513          	addi	a0,a0,1678 # 80017518 <bcache>
    80002e92:	ffffe097          	auipc	ra,0xffffe
    80002e96:	cd6080e7          	jalr	-810(ra) # 80000b68 <release>
}
    80002e9a:	60e2                	ld	ra,24(sp)
    80002e9c:	6442                	ld	s0,16(sp)
    80002e9e:	64a2                	ld	s1,8(sp)
    80002ea0:	6105                	addi	sp,sp,32
    80002ea2:	8082                	ret

0000000080002ea4 <bunpin>:

void
bunpin(struct buf *b) {
    80002ea4:	1101                	addi	sp,sp,-32
    80002ea6:	ec06                	sd	ra,24(sp)
    80002ea8:	e822                	sd	s0,16(sp)
    80002eaa:	e426                	sd	s1,8(sp)
    80002eac:	1000                	addi	s0,sp,32
    80002eae:	84aa                	mv	s1,a0
  acquire(&bcache.lock);
    80002eb0:	00014517          	auipc	a0,0x14
    80002eb4:	66850513          	addi	a0,a0,1640 # 80017518 <bcache>
    80002eb8:	ffffe097          	auipc	ra,0xffffe
    80002ebc:	c48080e7          	jalr	-952(ra) # 80000b00 <acquire>
  b->refcnt--;
    80002ec0:	40bc                	lw	a5,64(s1)
    80002ec2:	37fd                	addiw	a5,a5,-1
    80002ec4:	c0bc                	sw	a5,64(s1)
  release(&bcache.lock);
    80002ec6:	00014517          	auipc	a0,0x14
    80002eca:	65250513          	addi	a0,a0,1618 # 80017518 <bcache>
    80002ece:	ffffe097          	auipc	ra,0xffffe
    80002ed2:	c9a080e7          	jalr	-870(ra) # 80000b68 <release>
}
    80002ed6:	60e2                	ld	ra,24(sp)
    80002ed8:	6442                	ld	s0,16(sp)
    80002eda:	64a2                	ld	s1,8(sp)
    80002edc:	6105                	addi	sp,sp,32
    80002ede:	8082                	ret

0000000080002ee0 <bfree>:
}

// Free a disk block.
static void
bfree(int dev, uint b)
{
    80002ee0:	1101                	addi	sp,sp,-32
    80002ee2:	ec06                	sd	ra,24(sp)
    80002ee4:	e822                	sd	s0,16(sp)
    80002ee6:	e426                	sd	s1,8(sp)
    80002ee8:	e04a                	sd	s2,0(sp)
    80002eea:	1000                	addi	s0,sp,32
    80002eec:	84ae                	mv	s1,a1
  struct buf *bp;
  int bi, m;

  bp = bread(dev, BBLOCK(b, sb));
    80002eee:	00d5d59b          	srliw	a1,a1,0xd
    80002ef2:	0001d797          	auipc	a5,0x1d
    80002ef6:	dde78793          	addi	a5,a5,-546 # 8001fcd0 <sb>
    80002efa:	4fdc                	lw	a5,28(a5)
    80002efc:	9dbd                	addw	a1,a1,a5
    80002efe:	00000097          	auipc	ra,0x0
    80002f02:	d86080e7          	jalr	-634(ra) # 80002c84 <bread>
  bi = b % BPB;
    80002f06:	2481                	sext.w	s1,s1
  m = 1 << (bi % 8);
    80002f08:	0074f793          	andi	a5,s1,7
    80002f0c:	4705                	li	a4,1
    80002f0e:	00f7173b          	sllw	a4,a4,a5
  bi = b % BPB;
    80002f12:	6789                	lui	a5,0x2
    80002f14:	17fd                	addi	a5,a5,-1
    80002f16:	8cfd                	and	s1,s1,a5
  if((bp->data[bi/8] & m) == 0)
    80002f18:	41f4d79b          	sraiw	a5,s1,0x1f
    80002f1c:	01d7d79b          	srliw	a5,a5,0x1d
    80002f20:	9fa5                	addw	a5,a5,s1
    80002f22:	4037d79b          	sraiw	a5,a5,0x3
    80002f26:	00f506b3          	add	a3,a0,a5
    80002f2a:	0606c683          	lbu	a3,96(a3)
    80002f2e:	00d77633          	and	a2,a4,a3
    80002f32:	c61d                	beqz	a2,80002f60 <bfree+0x80>
    80002f34:	892a                	mv	s2,a0
    panic("freeing free block");
  bp->data[bi/8] &= ~m;
    80002f36:	97aa                	add	a5,a5,a0
    80002f38:	fff74713          	not	a4,a4
    80002f3c:	8f75                	and	a4,a4,a3
    80002f3e:	06e78023          	sb	a4,96(a5) # 2060 <_entry-0x7fffdfa0>
  log_write(bp);
    80002f42:	00001097          	auipc	ra,0x1
    80002f46:	1fa080e7          	jalr	506(ra) # 8000413c <log_write>
  brelse(bp);
    80002f4a:	854a                	mv	a0,s2
    80002f4c:	00000097          	auipc	ra,0x0
    80002f50:	e7e080e7          	jalr	-386(ra) # 80002dca <brelse>
}
    80002f54:	60e2                	ld	ra,24(sp)
    80002f56:	6442                	ld	s0,16(sp)
    80002f58:	64a2                	ld	s1,8(sp)
    80002f5a:	6902                	ld	s2,0(sp)
    80002f5c:	6105                	addi	sp,sp,32
    80002f5e:	8082                	ret
    panic("freeing free block");
    80002f60:	00004517          	auipc	a0,0x4
    80002f64:	5b850513          	addi	a0,a0,1464 # 80007518 <userret+0x488>
    80002f68:	ffffd097          	auipc	ra,0xffffd
    80002f6c:	616080e7          	jalr	1558(ra) # 8000057e <panic>

0000000080002f70 <balloc>:
{
    80002f70:	711d                	addi	sp,sp,-96
    80002f72:	ec86                	sd	ra,88(sp)
    80002f74:	e8a2                	sd	s0,80(sp)
    80002f76:	e4a6                	sd	s1,72(sp)
    80002f78:	e0ca                	sd	s2,64(sp)
    80002f7a:	fc4e                	sd	s3,56(sp)
    80002f7c:	f852                	sd	s4,48(sp)
    80002f7e:	f456                	sd	s5,40(sp)
    80002f80:	f05a                	sd	s6,32(sp)
    80002f82:	ec5e                	sd	s7,24(sp)
    80002f84:	e862                	sd	s8,16(sp)
    80002f86:	e466                	sd	s9,8(sp)
    80002f88:	1080                	addi	s0,sp,96
  for(b = 0; b < sb.size; b += BPB){
    80002f8a:	0001d797          	auipc	a5,0x1d
    80002f8e:	d4678793          	addi	a5,a5,-698 # 8001fcd0 <sb>
    80002f92:	43dc                	lw	a5,4(a5)
    80002f94:	10078e63          	beqz	a5,800030b0 <balloc+0x140>
    80002f98:	8baa                	mv	s7,a0
    80002f9a:	4a81                	li	s5,0
    bp = bread(dev, BBLOCK(b, sb));
    80002f9c:	0001db17          	auipc	s6,0x1d
    80002fa0:	d34b0b13          	addi	s6,s6,-716 # 8001fcd0 <sb>
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    80002fa4:	4c05                	li	s8,1
      m = 1 << (bi % 8);
    80002fa6:	4985                	li	s3,1
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    80002fa8:	6a09                	lui	s4,0x2
  for(b = 0; b < sb.size; b += BPB){
    80002faa:	6c89                	lui	s9,0x2
    80002fac:	a079                	j	8000303a <balloc+0xca>
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    80002fae:	8942                	mv	s2,a6
      m = 1 << (bi % 8);
    80002fb0:	4705                	li	a4,1
      if((bp->data[bi/8] & m) == 0){  // Is block free?
    80002fb2:	4681                	li	a3,0
        bp->data[bi/8] |= m;  // Mark block in use.
    80002fb4:	96a6                	add	a3,a3,s1
    80002fb6:	8f51                	or	a4,a4,a2
    80002fb8:	06e68023          	sb	a4,96(a3)
        log_write(bp);
    80002fbc:	8526                	mv	a0,s1
    80002fbe:	00001097          	auipc	ra,0x1
    80002fc2:	17e080e7          	jalr	382(ra) # 8000413c <log_write>
        brelse(bp);
    80002fc6:	8526                	mv	a0,s1
    80002fc8:	00000097          	auipc	ra,0x0
    80002fcc:	e02080e7          	jalr	-510(ra) # 80002dca <brelse>
  bp = bread(dev, bno);
    80002fd0:	85ca                	mv	a1,s2
    80002fd2:	855e                	mv	a0,s7
    80002fd4:	00000097          	auipc	ra,0x0
    80002fd8:	cb0080e7          	jalr	-848(ra) # 80002c84 <bread>
    80002fdc:	84aa                	mv	s1,a0
  memset(bp->data, 0, BSIZE);
    80002fde:	40000613          	li	a2,1024
    80002fe2:	4581                	li	a1,0
    80002fe4:	06050513          	addi	a0,a0,96
    80002fe8:	ffffe097          	auipc	ra,0xffffe
    80002fec:	bde080e7          	jalr	-1058(ra) # 80000bc6 <memset>
  log_write(bp);
    80002ff0:	8526                	mv	a0,s1
    80002ff2:	00001097          	auipc	ra,0x1
    80002ff6:	14a080e7          	jalr	330(ra) # 8000413c <log_write>
  brelse(bp);
    80002ffa:	8526                	mv	a0,s1
    80002ffc:	00000097          	auipc	ra,0x0
    80003000:	dce080e7          	jalr	-562(ra) # 80002dca <brelse>
}
    80003004:	854a                	mv	a0,s2
    80003006:	60e6                	ld	ra,88(sp)
    80003008:	6446                	ld	s0,80(sp)
    8000300a:	64a6                	ld	s1,72(sp)
    8000300c:	6906                	ld	s2,64(sp)
    8000300e:	79e2                	ld	s3,56(sp)
    80003010:	7a42                	ld	s4,48(sp)
    80003012:	7aa2                	ld	s5,40(sp)
    80003014:	7b02                	ld	s6,32(sp)
    80003016:	6be2                	ld	s7,24(sp)
    80003018:	6c42                	ld	s8,16(sp)
    8000301a:	6ca2                	ld	s9,8(sp)
    8000301c:	6125                	addi	sp,sp,96
    8000301e:	8082                	ret
    brelse(bp);
    80003020:	8526                	mv	a0,s1
    80003022:	00000097          	auipc	ra,0x0
    80003026:	da8080e7          	jalr	-600(ra) # 80002dca <brelse>
  for(b = 0; b < sb.size; b += BPB){
    8000302a:	015c87bb          	addw	a5,s9,s5
    8000302e:	00078a9b          	sext.w	s5,a5
    80003032:	004b2703          	lw	a4,4(s6)
    80003036:	06eafd63          	bleu	a4,s5,800030b0 <balloc+0x140>
    bp = bread(dev, BBLOCK(b, sb));
    8000303a:	41fad79b          	sraiw	a5,s5,0x1f
    8000303e:	0137d79b          	srliw	a5,a5,0x13
    80003042:	015787bb          	addw	a5,a5,s5
    80003046:	40d7d79b          	sraiw	a5,a5,0xd
    8000304a:	01cb2583          	lw	a1,28(s6)
    8000304e:	9dbd                	addw	a1,a1,a5
    80003050:	855e                	mv	a0,s7
    80003052:	00000097          	auipc	ra,0x0
    80003056:	c32080e7          	jalr	-974(ra) # 80002c84 <bread>
    8000305a:	84aa                	mv	s1,a0
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    8000305c:	000a881b          	sext.w	a6,s5
    80003060:	004b2503          	lw	a0,4(s6)
    80003064:	faa87ee3          	bleu	a0,a6,80003020 <balloc+0xb0>
      if((bp->data[bi/8] & m) == 0){  // Is block free?
    80003068:	0604c603          	lbu	a2,96(s1)
    8000306c:	00167793          	andi	a5,a2,1
    80003070:	df9d                	beqz	a5,80002fae <balloc+0x3e>
    80003072:	4105053b          	subw	a0,a0,a6
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    80003076:	87e2                	mv	a5,s8
    80003078:	0107893b          	addw	s2,a5,a6
    8000307c:	faa782e3          	beq	a5,a0,80003020 <balloc+0xb0>
      m = 1 << (bi % 8);
    80003080:	41f7d71b          	sraiw	a4,a5,0x1f
    80003084:	01d7561b          	srliw	a2,a4,0x1d
    80003088:	00f606bb          	addw	a3,a2,a5
    8000308c:	0076f713          	andi	a4,a3,7
    80003090:	9f11                	subw	a4,a4,a2
    80003092:	00e9973b          	sllw	a4,s3,a4
      if((bp->data[bi/8] & m) == 0){  // Is block free?
    80003096:	4036d69b          	sraiw	a3,a3,0x3
    8000309a:	00d48633          	add	a2,s1,a3
    8000309e:	06064603          	lbu	a2,96(a2)
    800030a2:	00c775b3          	and	a1,a4,a2
    800030a6:	d599                	beqz	a1,80002fb4 <balloc+0x44>
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    800030a8:	2785                	addiw	a5,a5,1
    800030aa:	fd4797e3          	bne	a5,s4,80003078 <balloc+0x108>
    800030ae:	bf8d                	j	80003020 <balloc+0xb0>
  panic("balloc: out of blocks");
    800030b0:	00004517          	auipc	a0,0x4
    800030b4:	48050513          	addi	a0,a0,1152 # 80007530 <userret+0x4a0>
    800030b8:	ffffd097          	auipc	ra,0xffffd
    800030bc:	4c6080e7          	jalr	1222(ra) # 8000057e <panic>

00000000800030c0 <bmap>:

// Return the disk block address of the nth block in inode ip.
// If there is no such block, bmap allocates one.
static uint
bmap(struct inode *ip, uint bn)
{
    800030c0:	7179                	addi	sp,sp,-48
    800030c2:	f406                	sd	ra,40(sp)
    800030c4:	f022                	sd	s0,32(sp)
    800030c6:	ec26                	sd	s1,24(sp)
    800030c8:	e84a                	sd	s2,16(sp)
    800030ca:	e44e                	sd	s3,8(sp)
    800030cc:	e052                	sd	s4,0(sp)
    800030ce:	1800                	addi	s0,sp,48
    800030d0:	89aa                	mv	s3,a0
  uint addr, *a;
  struct buf *bp;

  if(bn < NDIRECT){
    800030d2:	47ad                	li	a5,11
    800030d4:	04b7fe63          	bleu	a1,a5,80003130 <bmap+0x70>
    if((addr = ip->addrs[bn]) == 0)
      ip->addrs[bn] = addr = balloc(ip->dev);
    return addr;
  }
  bn -= NDIRECT;
    800030d8:	ff45849b          	addiw	s1,a1,-12
    800030dc:	0004871b          	sext.w	a4,s1

  if(bn < NINDIRECT){
    800030e0:	0ff00793          	li	a5,255
    800030e4:	0ae7e363          	bltu	a5,a4,8000318a <bmap+0xca>
    // Load indirect block, allocating if necessary.
    if((addr = ip->addrs[NDIRECT]) == 0)
    800030e8:	08052583          	lw	a1,128(a0)
    800030ec:	c5ad                	beqz	a1,80003156 <bmap+0x96>
      ip->addrs[NDIRECT] = addr = balloc(ip->dev);
    bp = bread(ip->dev, addr);
    800030ee:	0009a503          	lw	a0,0(s3)
    800030f2:	00000097          	auipc	ra,0x0
    800030f6:	b92080e7          	jalr	-1134(ra) # 80002c84 <bread>
    800030fa:	8a2a                	mv	s4,a0
    a = (uint*)bp->data;
    800030fc:	06050793          	addi	a5,a0,96
    if((addr = a[bn]) == 0){
    80003100:	02049593          	slli	a1,s1,0x20
    80003104:	9181                	srli	a1,a1,0x20
    80003106:	058a                	slli	a1,a1,0x2
    80003108:	00b784b3          	add	s1,a5,a1
    8000310c:	0004a903          	lw	s2,0(s1)
    80003110:	04090d63          	beqz	s2,8000316a <bmap+0xaa>
      a[bn] = addr = balloc(ip->dev);
      log_write(bp);
    }
    brelse(bp);
    80003114:	8552                	mv	a0,s4
    80003116:	00000097          	auipc	ra,0x0
    8000311a:	cb4080e7          	jalr	-844(ra) # 80002dca <brelse>
    return addr;
  }

  panic("bmap: out of range");
}
    8000311e:	854a                	mv	a0,s2
    80003120:	70a2                	ld	ra,40(sp)
    80003122:	7402                	ld	s0,32(sp)
    80003124:	64e2                	ld	s1,24(sp)
    80003126:	6942                	ld	s2,16(sp)
    80003128:	69a2                	ld	s3,8(sp)
    8000312a:	6a02                	ld	s4,0(sp)
    8000312c:	6145                	addi	sp,sp,48
    8000312e:	8082                	ret
    if((addr = ip->addrs[bn]) == 0)
    80003130:	02059493          	slli	s1,a1,0x20
    80003134:	9081                	srli	s1,s1,0x20
    80003136:	048a                	slli	s1,s1,0x2
    80003138:	94aa                	add	s1,s1,a0
    8000313a:	0504a903          	lw	s2,80(s1)
    8000313e:	fe0910e3          	bnez	s2,8000311e <bmap+0x5e>
      ip->addrs[bn] = addr = balloc(ip->dev);
    80003142:	4108                	lw	a0,0(a0)
    80003144:	00000097          	auipc	ra,0x0
    80003148:	e2c080e7          	jalr	-468(ra) # 80002f70 <balloc>
    8000314c:	0005091b          	sext.w	s2,a0
    80003150:	0524a823          	sw	s2,80(s1)
    80003154:	b7e9                	j	8000311e <bmap+0x5e>
      ip->addrs[NDIRECT] = addr = balloc(ip->dev);
    80003156:	4108                	lw	a0,0(a0)
    80003158:	00000097          	auipc	ra,0x0
    8000315c:	e18080e7          	jalr	-488(ra) # 80002f70 <balloc>
    80003160:	0005059b          	sext.w	a1,a0
    80003164:	08b9a023          	sw	a1,128(s3)
    80003168:	b759                	j	800030ee <bmap+0x2e>
      a[bn] = addr = balloc(ip->dev);
    8000316a:	0009a503          	lw	a0,0(s3)
    8000316e:	00000097          	auipc	ra,0x0
    80003172:	e02080e7          	jalr	-510(ra) # 80002f70 <balloc>
    80003176:	0005091b          	sext.w	s2,a0
    8000317a:	0124a023          	sw	s2,0(s1)
      log_write(bp);
    8000317e:	8552                	mv	a0,s4
    80003180:	00001097          	auipc	ra,0x1
    80003184:	fbc080e7          	jalr	-68(ra) # 8000413c <log_write>
    80003188:	b771                	j	80003114 <bmap+0x54>
  panic("bmap: out of range");
    8000318a:	00004517          	auipc	a0,0x4
    8000318e:	3be50513          	addi	a0,a0,958 # 80007548 <userret+0x4b8>
    80003192:	ffffd097          	auipc	ra,0xffffd
    80003196:	3ec080e7          	jalr	1004(ra) # 8000057e <panic>

000000008000319a <iget>:
{
    8000319a:	7179                	addi	sp,sp,-48
    8000319c:	f406                	sd	ra,40(sp)
    8000319e:	f022                	sd	s0,32(sp)
    800031a0:	ec26                	sd	s1,24(sp)
    800031a2:	e84a                	sd	s2,16(sp)
    800031a4:	e44e                	sd	s3,8(sp)
    800031a6:	e052                	sd	s4,0(sp)
    800031a8:	1800                	addi	s0,sp,48
    800031aa:	89aa                	mv	s3,a0
    800031ac:	8a2e                	mv	s4,a1
  acquire(&icache.lock);
    800031ae:	0001d517          	auipc	a0,0x1d
    800031b2:	b4250513          	addi	a0,a0,-1214 # 8001fcf0 <icache>
    800031b6:	ffffe097          	auipc	ra,0xffffe
    800031ba:	94a080e7          	jalr	-1718(ra) # 80000b00 <acquire>
  empty = 0;
    800031be:	4901                	li	s2,0
  for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){
    800031c0:	0001d497          	auipc	s1,0x1d
    800031c4:	b4848493          	addi	s1,s1,-1208 # 8001fd08 <icache+0x18>
    800031c8:	0001e697          	auipc	a3,0x1e
    800031cc:	5d068693          	addi	a3,a3,1488 # 80021798 <log>
    800031d0:	a039                	j	800031de <iget+0x44>
    if(empty == 0 && ip->ref == 0)    // Remember empty slot.
    800031d2:	02090b63          	beqz	s2,80003208 <iget+0x6e>
  for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){
    800031d6:	08848493          	addi	s1,s1,136
    800031da:	02d48a63          	beq	s1,a3,8000320e <iget+0x74>
    if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){
    800031de:	449c                	lw	a5,8(s1)
    800031e0:	fef059e3          	blez	a5,800031d2 <iget+0x38>
    800031e4:	4098                	lw	a4,0(s1)
    800031e6:	ff3716e3          	bne	a4,s3,800031d2 <iget+0x38>
    800031ea:	40d8                	lw	a4,4(s1)
    800031ec:	ff4713e3          	bne	a4,s4,800031d2 <iget+0x38>
      ip->ref++;
    800031f0:	2785                	addiw	a5,a5,1
    800031f2:	c49c                	sw	a5,8(s1)
      release(&icache.lock);
    800031f4:	0001d517          	auipc	a0,0x1d
    800031f8:	afc50513          	addi	a0,a0,-1284 # 8001fcf0 <icache>
    800031fc:	ffffe097          	auipc	ra,0xffffe
    80003200:	96c080e7          	jalr	-1684(ra) # 80000b68 <release>
      return ip;
    80003204:	8926                	mv	s2,s1
    80003206:	a03d                	j	80003234 <iget+0x9a>
    if(empty == 0 && ip->ref == 0)    // Remember empty slot.
    80003208:	f7f9                	bnez	a5,800031d6 <iget+0x3c>
    8000320a:	8926                	mv	s2,s1
    8000320c:	b7e9                	j	800031d6 <iget+0x3c>
  if(empty == 0)
    8000320e:	02090c63          	beqz	s2,80003246 <iget+0xac>
  ip->dev = dev;
    80003212:	01392023          	sw	s3,0(s2)
  ip->inum = inum;
    80003216:	01492223          	sw	s4,4(s2)
  ip->ref = 1;
    8000321a:	4785                	li	a5,1
    8000321c:	00f92423          	sw	a5,8(s2)
  ip->valid = 0;
    80003220:	04092023          	sw	zero,64(s2)
  release(&icache.lock);
    80003224:	0001d517          	auipc	a0,0x1d
    80003228:	acc50513          	addi	a0,a0,-1332 # 8001fcf0 <icache>
    8000322c:	ffffe097          	auipc	ra,0xffffe
    80003230:	93c080e7          	jalr	-1732(ra) # 80000b68 <release>
}
    80003234:	854a                	mv	a0,s2
    80003236:	70a2                	ld	ra,40(sp)
    80003238:	7402                	ld	s0,32(sp)
    8000323a:	64e2                	ld	s1,24(sp)
    8000323c:	6942                	ld	s2,16(sp)
    8000323e:	69a2                	ld	s3,8(sp)
    80003240:	6a02                	ld	s4,0(sp)
    80003242:	6145                	addi	sp,sp,48
    80003244:	8082                	ret
    panic("iget: no inodes");
    80003246:	00004517          	auipc	a0,0x4
    8000324a:	31a50513          	addi	a0,a0,794 # 80007560 <userret+0x4d0>
    8000324e:	ffffd097          	auipc	ra,0xffffd
    80003252:	330080e7          	jalr	816(ra) # 8000057e <panic>

0000000080003256 <fsinit>:
fsinit(int dev) {
    80003256:	7179                	addi	sp,sp,-48
    80003258:	f406                	sd	ra,40(sp)
    8000325a:	f022                	sd	s0,32(sp)
    8000325c:	ec26                	sd	s1,24(sp)
    8000325e:	e84a                	sd	s2,16(sp)
    80003260:	e44e                	sd	s3,8(sp)
    80003262:	1800                	addi	s0,sp,48
    80003264:	89aa                	mv	s3,a0
  bp = bread(dev, 1);
    80003266:	4585                	li	a1,1
    80003268:	00000097          	auipc	ra,0x0
    8000326c:	a1c080e7          	jalr	-1508(ra) # 80002c84 <bread>
    80003270:	892a                	mv	s2,a0
  memmove(sb, bp->data, sizeof(*sb));
    80003272:	0001d497          	auipc	s1,0x1d
    80003276:	a5e48493          	addi	s1,s1,-1442 # 8001fcd0 <sb>
    8000327a:	02000613          	li	a2,32
    8000327e:	06050593          	addi	a1,a0,96
    80003282:	8526                	mv	a0,s1
    80003284:	ffffe097          	auipc	ra,0xffffe
    80003288:	9ae080e7          	jalr	-1618(ra) # 80000c32 <memmove>
  brelse(bp);
    8000328c:	854a                	mv	a0,s2
    8000328e:	00000097          	auipc	ra,0x0
    80003292:	b3c080e7          	jalr	-1220(ra) # 80002dca <brelse>
  if(sb.magic != FSMAGIC)
    80003296:	4098                	lw	a4,0(s1)
    80003298:	102037b7          	lui	a5,0x10203
    8000329c:	04078793          	addi	a5,a5,64 # 10203040 <_entry-0x6fdfcfc0>
    800032a0:	02f71263          	bne	a4,a5,800032c4 <fsinit+0x6e>
  initlog(dev, &sb);
    800032a4:	0001d597          	auipc	a1,0x1d
    800032a8:	a2c58593          	addi	a1,a1,-1492 # 8001fcd0 <sb>
    800032ac:	854e                	mv	a0,s3
    800032ae:	00001097          	auipc	ra,0x1
    800032b2:	c08080e7          	jalr	-1016(ra) # 80003eb6 <initlog>
}
    800032b6:	70a2                	ld	ra,40(sp)
    800032b8:	7402                	ld	s0,32(sp)
    800032ba:	64e2                	ld	s1,24(sp)
    800032bc:	6942                	ld	s2,16(sp)
    800032be:	69a2                	ld	s3,8(sp)
    800032c0:	6145                	addi	sp,sp,48
    800032c2:	8082                	ret
    panic("invalid file system");
    800032c4:	00004517          	auipc	a0,0x4
    800032c8:	2ac50513          	addi	a0,a0,684 # 80007570 <userret+0x4e0>
    800032cc:	ffffd097          	auipc	ra,0xffffd
    800032d0:	2b2080e7          	jalr	690(ra) # 8000057e <panic>

00000000800032d4 <iinit>:
{
    800032d4:	7179                	addi	sp,sp,-48
    800032d6:	f406                	sd	ra,40(sp)
    800032d8:	f022                	sd	s0,32(sp)
    800032da:	ec26                	sd	s1,24(sp)
    800032dc:	e84a                	sd	s2,16(sp)
    800032de:	e44e                	sd	s3,8(sp)
    800032e0:	1800                	addi	s0,sp,48
  initlock(&icache.lock, "icache");
    800032e2:	00004597          	auipc	a1,0x4
    800032e6:	2a658593          	addi	a1,a1,678 # 80007588 <userret+0x4f8>
    800032ea:	0001d517          	auipc	a0,0x1d
    800032ee:	a0650513          	addi	a0,a0,-1530 # 8001fcf0 <icache>
    800032f2:	ffffd097          	auipc	ra,0xffffd
    800032f6:	700080e7          	jalr	1792(ra) # 800009f2 <initlock>
  for(i = 0; i < NINODE; i++) {
    800032fa:	0001d497          	auipc	s1,0x1d
    800032fe:	a1e48493          	addi	s1,s1,-1506 # 8001fd18 <icache+0x28>
    80003302:	0001e997          	auipc	s3,0x1e
    80003306:	4a698993          	addi	s3,s3,1190 # 800217a8 <log+0x10>
    initsleeplock(&icache.inode[i].lock, "inode");
    8000330a:	00004917          	auipc	s2,0x4
    8000330e:	28690913          	addi	s2,s2,646 # 80007590 <userret+0x500>
    80003312:	85ca                	mv	a1,s2
    80003314:	8526                	mv	a0,s1
    80003316:	00001097          	auipc	ra,0x1
    8000331a:	0a2080e7          	jalr	162(ra) # 800043b8 <initsleeplock>
  for(i = 0; i < NINODE; i++) {
    8000331e:	08848493          	addi	s1,s1,136
    80003322:	ff3498e3          	bne	s1,s3,80003312 <iinit+0x3e>
}
    80003326:	70a2                	ld	ra,40(sp)
    80003328:	7402                	ld	s0,32(sp)
    8000332a:	64e2                	ld	s1,24(sp)
    8000332c:	6942                	ld	s2,16(sp)
    8000332e:	69a2                	ld	s3,8(sp)
    80003330:	6145                	addi	sp,sp,48
    80003332:	8082                	ret

0000000080003334 <ialloc>:
{
    80003334:	715d                	addi	sp,sp,-80
    80003336:	e486                	sd	ra,72(sp)
    80003338:	e0a2                	sd	s0,64(sp)
    8000333a:	fc26                	sd	s1,56(sp)
    8000333c:	f84a                	sd	s2,48(sp)
    8000333e:	f44e                	sd	s3,40(sp)
    80003340:	f052                	sd	s4,32(sp)
    80003342:	ec56                	sd	s5,24(sp)
    80003344:	e85a                	sd	s6,16(sp)
    80003346:	e45e                	sd	s7,8(sp)
    80003348:	0880                	addi	s0,sp,80
  for(inum = 1; inum < sb.ninodes; inum++){
    8000334a:	0001d797          	auipc	a5,0x1d
    8000334e:	98678793          	addi	a5,a5,-1658 # 8001fcd0 <sb>
    80003352:	47d8                	lw	a4,12(a5)
    80003354:	4785                	li	a5,1
    80003356:	04e7fa63          	bleu	a4,a5,800033aa <ialloc+0x76>
    8000335a:	8a2a                	mv	s4,a0
    8000335c:	8b2e                	mv	s6,a1
    8000335e:	4485                	li	s1,1
    bp = bread(dev, IBLOCK(inum, sb));
    80003360:	0001d997          	auipc	s3,0x1d
    80003364:	97098993          	addi	s3,s3,-1680 # 8001fcd0 <sb>
    80003368:	00048a9b          	sext.w	s5,s1
    8000336c:	0044d593          	srli	a1,s1,0x4
    80003370:	0189a783          	lw	a5,24(s3)
    80003374:	9dbd                	addw	a1,a1,a5
    80003376:	8552                	mv	a0,s4
    80003378:	00000097          	auipc	ra,0x0
    8000337c:	90c080e7          	jalr	-1780(ra) # 80002c84 <bread>
    80003380:	8baa                	mv	s7,a0
    dip = (struct dinode*)bp->data + inum%IPB;
    80003382:	06050913          	addi	s2,a0,96
    80003386:	00f4f793          	andi	a5,s1,15
    8000338a:	079a                	slli	a5,a5,0x6
    8000338c:	993e                	add	s2,s2,a5
    if(dip->type == 0){  // a free inode
    8000338e:	00091783          	lh	a5,0(s2)
    80003392:	c785                	beqz	a5,800033ba <ialloc+0x86>
    brelse(bp);
    80003394:	00000097          	auipc	ra,0x0
    80003398:	a36080e7          	jalr	-1482(ra) # 80002dca <brelse>
  for(inum = 1; inum < sb.ninodes; inum++){
    8000339c:	0485                	addi	s1,s1,1
    8000339e:	00c9a703          	lw	a4,12(s3)
    800033a2:	0004879b          	sext.w	a5,s1
    800033a6:	fce7e1e3          	bltu	a5,a4,80003368 <ialloc+0x34>
  panic("ialloc: no inodes");
    800033aa:	00004517          	auipc	a0,0x4
    800033ae:	1ee50513          	addi	a0,a0,494 # 80007598 <userret+0x508>
    800033b2:	ffffd097          	auipc	ra,0xffffd
    800033b6:	1cc080e7          	jalr	460(ra) # 8000057e <panic>
      memset(dip, 0, sizeof(*dip));
    800033ba:	04000613          	li	a2,64
    800033be:	4581                	li	a1,0
    800033c0:	854a                	mv	a0,s2
    800033c2:	ffffe097          	auipc	ra,0xffffe
    800033c6:	804080e7          	jalr	-2044(ra) # 80000bc6 <memset>
      dip->type = type;
    800033ca:	01691023          	sh	s6,0(s2)
      log_write(bp);   // mark it allocated on the disk
    800033ce:	855e                	mv	a0,s7
    800033d0:	00001097          	auipc	ra,0x1
    800033d4:	d6c080e7          	jalr	-660(ra) # 8000413c <log_write>
      brelse(bp);
    800033d8:	855e                	mv	a0,s7
    800033da:	00000097          	auipc	ra,0x0
    800033de:	9f0080e7          	jalr	-1552(ra) # 80002dca <brelse>
      return iget(dev, inum);
    800033e2:	85d6                	mv	a1,s5
    800033e4:	8552                	mv	a0,s4
    800033e6:	00000097          	auipc	ra,0x0
    800033ea:	db4080e7          	jalr	-588(ra) # 8000319a <iget>
}
    800033ee:	60a6                	ld	ra,72(sp)
    800033f0:	6406                	ld	s0,64(sp)
    800033f2:	74e2                	ld	s1,56(sp)
    800033f4:	7942                	ld	s2,48(sp)
    800033f6:	79a2                	ld	s3,40(sp)
    800033f8:	7a02                	ld	s4,32(sp)
    800033fa:	6ae2                	ld	s5,24(sp)
    800033fc:	6b42                	ld	s6,16(sp)
    800033fe:	6ba2                	ld	s7,8(sp)
    80003400:	6161                	addi	sp,sp,80
    80003402:	8082                	ret

0000000080003404 <iupdate>:
{
    80003404:	1101                	addi	sp,sp,-32
    80003406:	ec06                	sd	ra,24(sp)
    80003408:	e822                	sd	s0,16(sp)
    8000340a:	e426                	sd	s1,8(sp)
    8000340c:	e04a                	sd	s2,0(sp)
    8000340e:	1000                	addi	s0,sp,32
    80003410:	84aa                	mv	s1,a0
  bp = bread(ip->dev, IBLOCK(ip->inum, sb));
    80003412:	415c                	lw	a5,4(a0)
    80003414:	0047d79b          	srliw	a5,a5,0x4
    80003418:	0001d717          	auipc	a4,0x1d
    8000341c:	8b870713          	addi	a4,a4,-1864 # 8001fcd0 <sb>
    80003420:	4f0c                	lw	a1,24(a4)
    80003422:	9dbd                	addw	a1,a1,a5
    80003424:	4108                	lw	a0,0(a0)
    80003426:	00000097          	auipc	ra,0x0
    8000342a:	85e080e7          	jalr	-1954(ra) # 80002c84 <bread>
    8000342e:	892a                	mv	s2,a0
  dip = (struct dinode*)bp->data + ip->inum%IPB;
    80003430:	06050513          	addi	a0,a0,96
    80003434:	40dc                	lw	a5,4(s1)
    80003436:	8bbd                	andi	a5,a5,15
    80003438:	079a                	slli	a5,a5,0x6
    8000343a:	953e                	add	a0,a0,a5
  dip->type = ip->type;
    8000343c:	04449783          	lh	a5,68(s1)
    80003440:	00f51023          	sh	a5,0(a0)
  dip->major = ip->major;
    80003444:	04649783          	lh	a5,70(s1)
    80003448:	00f51123          	sh	a5,2(a0)
  dip->minor = ip->minor;
    8000344c:	04849783          	lh	a5,72(s1)
    80003450:	00f51223          	sh	a5,4(a0)
  dip->nlink = ip->nlink;
    80003454:	04a49783          	lh	a5,74(s1)
    80003458:	00f51323          	sh	a5,6(a0)
  dip->size = ip->size;
    8000345c:	44fc                	lw	a5,76(s1)
    8000345e:	c51c                	sw	a5,8(a0)
  memmove(dip->addrs, ip->addrs, sizeof(ip->addrs));
    80003460:	03400613          	li	a2,52
    80003464:	05048593          	addi	a1,s1,80
    80003468:	0531                	addi	a0,a0,12
    8000346a:	ffffd097          	auipc	ra,0xffffd
    8000346e:	7c8080e7          	jalr	1992(ra) # 80000c32 <memmove>
  log_write(bp);
    80003472:	854a                	mv	a0,s2
    80003474:	00001097          	auipc	ra,0x1
    80003478:	cc8080e7          	jalr	-824(ra) # 8000413c <log_write>
  brelse(bp);
    8000347c:	854a                	mv	a0,s2
    8000347e:	00000097          	auipc	ra,0x0
    80003482:	94c080e7          	jalr	-1716(ra) # 80002dca <brelse>
}
    80003486:	60e2                	ld	ra,24(sp)
    80003488:	6442                	ld	s0,16(sp)
    8000348a:	64a2                	ld	s1,8(sp)
    8000348c:	6902                	ld	s2,0(sp)
    8000348e:	6105                	addi	sp,sp,32
    80003490:	8082                	ret

0000000080003492 <idup>:
{
    80003492:	1101                	addi	sp,sp,-32
    80003494:	ec06                	sd	ra,24(sp)
    80003496:	e822                	sd	s0,16(sp)
    80003498:	e426                	sd	s1,8(sp)
    8000349a:	1000                	addi	s0,sp,32
    8000349c:	84aa                	mv	s1,a0
  acquire(&icache.lock);
    8000349e:	0001d517          	auipc	a0,0x1d
    800034a2:	85250513          	addi	a0,a0,-1966 # 8001fcf0 <icache>
    800034a6:	ffffd097          	auipc	ra,0xffffd
    800034aa:	65a080e7          	jalr	1626(ra) # 80000b00 <acquire>
  ip->ref++;
    800034ae:	449c                	lw	a5,8(s1)
    800034b0:	2785                	addiw	a5,a5,1
    800034b2:	c49c                	sw	a5,8(s1)
  release(&icache.lock);
    800034b4:	0001d517          	auipc	a0,0x1d
    800034b8:	83c50513          	addi	a0,a0,-1988 # 8001fcf0 <icache>
    800034bc:	ffffd097          	auipc	ra,0xffffd
    800034c0:	6ac080e7          	jalr	1708(ra) # 80000b68 <release>
}
    800034c4:	8526                	mv	a0,s1
    800034c6:	60e2                	ld	ra,24(sp)
    800034c8:	6442                	ld	s0,16(sp)
    800034ca:	64a2                	ld	s1,8(sp)
    800034cc:	6105                	addi	sp,sp,32
    800034ce:	8082                	ret

00000000800034d0 <ilock>:
{
    800034d0:	1101                	addi	sp,sp,-32
    800034d2:	ec06                	sd	ra,24(sp)
    800034d4:	e822                	sd	s0,16(sp)
    800034d6:	e426                	sd	s1,8(sp)
    800034d8:	e04a                	sd	s2,0(sp)
    800034da:	1000                	addi	s0,sp,32
  if(ip == 0 || ip->ref < 1)
    800034dc:	c115                	beqz	a0,80003500 <ilock+0x30>
    800034de:	84aa                	mv	s1,a0
    800034e0:	451c                	lw	a5,8(a0)
    800034e2:	00f05f63          	blez	a5,80003500 <ilock+0x30>
  acquiresleep(&ip->lock);
    800034e6:	0541                	addi	a0,a0,16
    800034e8:	00001097          	auipc	ra,0x1
    800034ec:	f0a080e7          	jalr	-246(ra) # 800043f2 <acquiresleep>
  if(ip->valid == 0){
    800034f0:	40bc                	lw	a5,64(s1)
    800034f2:	cf99                	beqz	a5,80003510 <ilock+0x40>
}
    800034f4:	60e2                	ld	ra,24(sp)
    800034f6:	6442                	ld	s0,16(sp)
    800034f8:	64a2                	ld	s1,8(sp)
    800034fa:	6902                	ld	s2,0(sp)
    800034fc:	6105                	addi	sp,sp,32
    800034fe:	8082                	ret
    panic("ilock");
    80003500:	00004517          	auipc	a0,0x4
    80003504:	0b050513          	addi	a0,a0,176 # 800075b0 <userret+0x520>
    80003508:	ffffd097          	auipc	ra,0xffffd
    8000350c:	076080e7          	jalr	118(ra) # 8000057e <panic>
    bp = bread(ip->dev, IBLOCK(ip->inum, sb));
    80003510:	40dc                	lw	a5,4(s1)
    80003512:	0047d79b          	srliw	a5,a5,0x4
    80003516:	0001c717          	auipc	a4,0x1c
    8000351a:	7ba70713          	addi	a4,a4,1978 # 8001fcd0 <sb>
    8000351e:	4f0c                	lw	a1,24(a4)
    80003520:	9dbd                	addw	a1,a1,a5
    80003522:	4088                	lw	a0,0(s1)
    80003524:	fffff097          	auipc	ra,0xfffff
    80003528:	760080e7          	jalr	1888(ra) # 80002c84 <bread>
    8000352c:	892a                	mv	s2,a0
    dip = (struct dinode*)bp->data + ip->inum%IPB;
    8000352e:	06050593          	addi	a1,a0,96
    80003532:	40dc                	lw	a5,4(s1)
    80003534:	8bbd                	andi	a5,a5,15
    80003536:	079a                	slli	a5,a5,0x6
    80003538:	95be                	add	a1,a1,a5
    ip->type = dip->type;
    8000353a:	00059783          	lh	a5,0(a1)
    8000353e:	04f49223          	sh	a5,68(s1)
    ip->major = dip->major;
    80003542:	00259783          	lh	a5,2(a1)
    80003546:	04f49323          	sh	a5,70(s1)
    ip->minor = dip->minor;
    8000354a:	00459783          	lh	a5,4(a1)
    8000354e:	04f49423          	sh	a5,72(s1)
    ip->nlink = dip->nlink;
    80003552:	00659783          	lh	a5,6(a1)
    80003556:	04f49523          	sh	a5,74(s1)
    ip->size = dip->size;
    8000355a:	459c                	lw	a5,8(a1)
    8000355c:	c4fc                	sw	a5,76(s1)
    memmove(ip->addrs, dip->addrs, sizeof(ip->addrs));
    8000355e:	03400613          	li	a2,52
    80003562:	05b1                	addi	a1,a1,12
    80003564:	05048513          	addi	a0,s1,80
    80003568:	ffffd097          	auipc	ra,0xffffd
    8000356c:	6ca080e7          	jalr	1738(ra) # 80000c32 <memmove>
    brelse(bp);
    80003570:	854a                	mv	a0,s2
    80003572:	00000097          	auipc	ra,0x0
    80003576:	858080e7          	jalr	-1960(ra) # 80002dca <brelse>
    ip->valid = 1;
    8000357a:	4785                	li	a5,1
    8000357c:	c0bc                	sw	a5,64(s1)
    if(ip->type == 0)
    8000357e:	04449783          	lh	a5,68(s1)
    80003582:	fbad                	bnez	a5,800034f4 <ilock+0x24>
      panic("ilock: no type");
    80003584:	00004517          	auipc	a0,0x4
    80003588:	03450513          	addi	a0,a0,52 # 800075b8 <userret+0x528>
    8000358c:	ffffd097          	auipc	ra,0xffffd
    80003590:	ff2080e7          	jalr	-14(ra) # 8000057e <panic>

0000000080003594 <iunlock>:
{
    80003594:	1101                	addi	sp,sp,-32
    80003596:	ec06                	sd	ra,24(sp)
    80003598:	e822                	sd	s0,16(sp)
    8000359a:	e426                	sd	s1,8(sp)
    8000359c:	e04a                	sd	s2,0(sp)
    8000359e:	1000                	addi	s0,sp,32
  if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1)
    800035a0:	c905                	beqz	a0,800035d0 <iunlock+0x3c>
    800035a2:	84aa                	mv	s1,a0
    800035a4:	01050913          	addi	s2,a0,16
    800035a8:	854a                	mv	a0,s2
    800035aa:	00001097          	auipc	ra,0x1
    800035ae:	ee2080e7          	jalr	-286(ra) # 8000448c <holdingsleep>
    800035b2:	cd19                	beqz	a0,800035d0 <iunlock+0x3c>
    800035b4:	449c                	lw	a5,8(s1)
    800035b6:	00f05d63          	blez	a5,800035d0 <iunlock+0x3c>
  releasesleep(&ip->lock);
    800035ba:	854a                	mv	a0,s2
    800035bc:	00001097          	auipc	ra,0x1
    800035c0:	e8c080e7          	jalr	-372(ra) # 80004448 <releasesleep>
}
    800035c4:	60e2                	ld	ra,24(sp)
    800035c6:	6442                	ld	s0,16(sp)
    800035c8:	64a2                	ld	s1,8(sp)
    800035ca:	6902                	ld	s2,0(sp)
    800035cc:	6105                	addi	sp,sp,32
    800035ce:	8082                	ret
    panic("iunlock");
    800035d0:	00004517          	auipc	a0,0x4
    800035d4:	ff850513          	addi	a0,a0,-8 # 800075c8 <userret+0x538>
    800035d8:	ffffd097          	auipc	ra,0xffffd
    800035dc:	fa6080e7          	jalr	-90(ra) # 8000057e <panic>

00000000800035e0 <iput>:
{
    800035e0:	7139                	addi	sp,sp,-64
    800035e2:	fc06                	sd	ra,56(sp)
    800035e4:	f822                	sd	s0,48(sp)
    800035e6:	f426                	sd	s1,40(sp)
    800035e8:	f04a                	sd	s2,32(sp)
    800035ea:	ec4e                	sd	s3,24(sp)
    800035ec:	e852                	sd	s4,16(sp)
    800035ee:	e456                	sd	s5,8(sp)
    800035f0:	0080                	addi	s0,sp,64
    800035f2:	84aa                	mv	s1,a0
  acquire(&icache.lock);
    800035f4:	0001c517          	auipc	a0,0x1c
    800035f8:	6fc50513          	addi	a0,a0,1788 # 8001fcf0 <icache>
    800035fc:	ffffd097          	auipc	ra,0xffffd
    80003600:	504080e7          	jalr	1284(ra) # 80000b00 <acquire>
  if(ip->ref == 1 && ip->valid && ip->nlink == 0){
    80003604:	4498                	lw	a4,8(s1)
    80003606:	4785                	li	a5,1
    80003608:	02f70663          	beq	a4,a5,80003634 <iput+0x54>
  ip->ref--;
    8000360c:	449c                	lw	a5,8(s1)
    8000360e:	37fd                	addiw	a5,a5,-1
    80003610:	c49c                	sw	a5,8(s1)
  release(&icache.lock);
    80003612:	0001c517          	auipc	a0,0x1c
    80003616:	6de50513          	addi	a0,a0,1758 # 8001fcf0 <icache>
    8000361a:	ffffd097          	auipc	ra,0xffffd
    8000361e:	54e080e7          	jalr	1358(ra) # 80000b68 <release>
}
    80003622:	70e2                	ld	ra,56(sp)
    80003624:	7442                	ld	s0,48(sp)
    80003626:	74a2                	ld	s1,40(sp)
    80003628:	7902                	ld	s2,32(sp)
    8000362a:	69e2                	ld	s3,24(sp)
    8000362c:	6a42                	ld	s4,16(sp)
    8000362e:	6aa2                	ld	s5,8(sp)
    80003630:	6121                	addi	sp,sp,64
    80003632:	8082                	ret
  if(ip->ref == 1 && ip->valid && ip->nlink == 0){
    80003634:	40bc                	lw	a5,64(s1)
    80003636:	dbf9                	beqz	a5,8000360c <iput+0x2c>
    80003638:	04a49783          	lh	a5,74(s1)
    8000363c:	fbe1                	bnez	a5,8000360c <iput+0x2c>
    acquiresleep(&ip->lock);
    8000363e:	01048a13          	addi	s4,s1,16
    80003642:	8552                	mv	a0,s4
    80003644:	00001097          	auipc	ra,0x1
    80003648:	dae080e7          	jalr	-594(ra) # 800043f2 <acquiresleep>
    release(&icache.lock);
    8000364c:	0001c517          	auipc	a0,0x1c
    80003650:	6a450513          	addi	a0,a0,1700 # 8001fcf0 <icache>
    80003654:	ffffd097          	auipc	ra,0xffffd
    80003658:	514080e7          	jalr	1300(ra) # 80000b68 <release>
{
  int i, j;
  struct buf *bp;
  uint *a;

  for(i = 0; i < NDIRECT; i++){
    8000365c:	05048913          	addi	s2,s1,80
    80003660:	08048993          	addi	s3,s1,128
    80003664:	a819                	j	8000367a <iput+0x9a>
    if(ip->addrs[i]){
      bfree(ip->dev, ip->addrs[i]);
    80003666:	4088                	lw	a0,0(s1)
    80003668:	00000097          	auipc	ra,0x0
    8000366c:	878080e7          	jalr	-1928(ra) # 80002ee0 <bfree>
      ip->addrs[i] = 0;
    80003670:	00092023          	sw	zero,0(s2)
  for(i = 0; i < NDIRECT; i++){
    80003674:	0911                	addi	s2,s2,4
    80003676:	01390663          	beq	s2,s3,80003682 <iput+0xa2>
    if(ip->addrs[i]){
    8000367a:	00092583          	lw	a1,0(s2)
    8000367e:	d9fd                	beqz	a1,80003674 <iput+0x94>
    80003680:	b7dd                	j	80003666 <iput+0x86>
    }
  }

  if(ip->addrs[NDIRECT]){
    80003682:	0804a583          	lw	a1,128(s1)
    80003686:	ed9d                	bnez	a1,800036c4 <iput+0xe4>
    brelse(bp);
    bfree(ip->dev, ip->addrs[NDIRECT]);
    ip->addrs[NDIRECT] = 0;
  }

  ip->size = 0;
    80003688:	0404a623          	sw	zero,76(s1)
  iupdate(ip);
    8000368c:	8526                	mv	a0,s1
    8000368e:	00000097          	auipc	ra,0x0
    80003692:	d76080e7          	jalr	-650(ra) # 80003404 <iupdate>
    ip->type = 0;
    80003696:	04049223          	sh	zero,68(s1)
    iupdate(ip);
    8000369a:	8526                	mv	a0,s1
    8000369c:	00000097          	auipc	ra,0x0
    800036a0:	d68080e7          	jalr	-664(ra) # 80003404 <iupdate>
    ip->valid = 0;
    800036a4:	0404a023          	sw	zero,64(s1)
    releasesleep(&ip->lock);
    800036a8:	8552                	mv	a0,s4
    800036aa:	00001097          	auipc	ra,0x1
    800036ae:	d9e080e7          	jalr	-610(ra) # 80004448 <releasesleep>
    acquire(&icache.lock);
    800036b2:	0001c517          	auipc	a0,0x1c
    800036b6:	63e50513          	addi	a0,a0,1598 # 8001fcf0 <icache>
    800036ba:	ffffd097          	auipc	ra,0xffffd
    800036be:	446080e7          	jalr	1094(ra) # 80000b00 <acquire>
    800036c2:	b7a9                	j	8000360c <iput+0x2c>
    bp = bread(ip->dev, ip->addrs[NDIRECT]);
    800036c4:	4088                	lw	a0,0(s1)
    800036c6:	fffff097          	auipc	ra,0xfffff
    800036ca:	5be080e7          	jalr	1470(ra) # 80002c84 <bread>
    800036ce:	8aaa                	mv	s5,a0
    for(j = 0; j < NINDIRECT; j++){
    800036d0:	06050913          	addi	s2,a0,96
    800036d4:	46050993          	addi	s3,a0,1120
    800036d8:	a809                	j	800036ea <iput+0x10a>
        bfree(ip->dev, a[j]);
    800036da:	4088                	lw	a0,0(s1)
    800036dc:	00000097          	auipc	ra,0x0
    800036e0:	804080e7          	jalr	-2044(ra) # 80002ee0 <bfree>
    for(j = 0; j < NINDIRECT; j++){
    800036e4:	0911                	addi	s2,s2,4
    800036e6:	01390663          	beq	s2,s3,800036f2 <iput+0x112>
      if(a[j])
    800036ea:	00092583          	lw	a1,0(s2)
    800036ee:	d9fd                	beqz	a1,800036e4 <iput+0x104>
    800036f0:	b7ed                	j	800036da <iput+0xfa>
    brelse(bp);
    800036f2:	8556                	mv	a0,s5
    800036f4:	fffff097          	auipc	ra,0xfffff
    800036f8:	6d6080e7          	jalr	1750(ra) # 80002dca <brelse>
    bfree(ip->dev, ip->addrs[NDIRECT]);
    800036fc:	0804a583          	lw	a1,128(s1)
    80003700:	4088                	lw	a0,0(s1)
    80003702:	fffff097          	auipc	ra,0xfffff
    80003706:	7de080e7          	jalr	2014(ra) # 80002ee0 <bfree>
    ip->addrs[NDIRECT] = 0;
    8000370a:	0804a023          	sw	zero,128(s1)
    8000370e:	bfad                	j	80003688 <iput+0xa8>

0000000080003710 <iunlockput>:
{
    80003710:	1101                	addi	sp,sp,-32
    80003712:	ec06                	sd	ra,24(sp)
    80003714:	e822                	sd	s0,16(sp)
    80003716:	e426                	sd	s1,8(sp)
    80003718:	1000                	addi	s0,sp,32
    8000371a:	84aa                	mv	s1,a0
  iunlock(ip);
    8000371c:	00000097          	auipc	ra,0x0
    80003720:	e78080e7          	jalr	-392(ra) # 80003594 <iunlock>
  iput(ip);
    80003724:	8526                	mv	a0,s1
    80003726:	00000097          	auipc	ra,0x0
    8000372a:	eba080e7          	jalr	-326(ra) # 800035e0 <iput>
}
    8000372e:	60e2                	ld	ra,24(sp)
    80003730:	6442                	ld	s0,16(sp)
    80003732:	64a2                	ld	s1,8(sp)
    80003734:	6105                	addi	sp,sp,32
    80003736:	8082                	ret

0000000080003738 <stati>:

// Copy stat information from inode.
// Caller must hold ip->lock.
void
stati(struct inode *ip, struct stat *st)
{
    80003738:	1141                	addi	sp,sp,-16
    8000373a:	e422                	sd	s0,8(sp)
    8000373c:	0800                	addi	s0,sp,16
  st->dev = ip->dev;
    8000373e:	411c                	lw	a5,0(a0)
    80003740:	c19c                	sw	a5,0(a1)
  st->ino = ip->inum;
    80003742:	415c                	lw	a5,4(a0)
    80003744:	c1dc                	sw	a5,4(a1)
  st->type = ip->type;
    80003746:	04451783          	lh	a5,68(a0)
    8000374a:	00f59423          	sh	a5,8(a1)
  st->nlink = ip->nlink;
    8000374e:	04a51783          	lh	a5,74(a0)
    80003752:	00f59523          	sh	a5,10(a1)
  st->size = ip->size;
    80003756:	04c56783          	lwu	a5,76(a0)
    8000375a:	e99c                	sd	a5,16(a1)
}
    8000375c:	6422                	ld	s0,8(sp)
    8000375e:	0141                	addi	sp,sp,16
    80003760:	8082                	ret

0000000080003762 <readi>:
readi(struct inode *ip, int user_dst, uint64 dst, uint off, uint n)
{
  uint tot, m;
  struct buf *bp;

  if(off > ip->size || off + n < off)
    80003762:	457c                	lw	a5,76(a0)
    80003764:	0ed7e563          	bltu	a5,a3,8000384e <readi+0xec>
{
    80003768:	7159                	addi	sp,sp,-112
    8000376a:	f486                	sd	ra,104(sp)
    8000376c:	f0a2                	sd	s0,96(sp)
    8000376e:	eca6                	sd	s1,88(sp)
    80003770:	e8ca                	sd	s2,80(sp)
    80003772:	e4ce                	sd	s3,72(sp)
    80003774:	e0d2                	sd	s4,64(sp)
    80003776:	fc56                	sd	s5,56(sp)
    80003778:	f85a                	sd	s6,48(sp)
    8000377a:	f45e                	sd	s7,40(sp)
    8000377c:	f062                	sd	s8,32(sp)
    8000377e:	ec66                	sd	s9,24(sp)
    80003780:	e86a                	sd	s10,16(sp)
    80003782:	e46e                	sd	s11,8(sp)
    80003784:	1880                	addi	s0,sp,112
    80003786:	8baa                	mv	s7,a0
    80003788:	8c2e                	mv	s8,a1
    8000378a:	8a32                	mv	s4,a2
    8000378c:	84b6                	mv	s1,a3
    8000378e:	8b3a                	mv	s6,a4
  if(off > ip->size || off + n < off)
    80003790:	9f35                	addw	a4,a4,a3
    80003792:	0cd76063          	bltu	a4,a3,80003852 <readi+0xf0>
    return -1;
  if(off + n > ip->size)
    80003796:	00e7f463          	bleu	a4,a5,8000379e <readi+0x3c>
    n = ip->size - off;
    8000379a:	40d78b3b          	subw	s6,a5,a3

  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
    8000379e:	080b0763          	beqz	s6,8000382c <readi+0xca>
    800037a2:	4981                	li	s3,0
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
    800037a4:	40000d13          	li	s10,1024
    if(either_copyout(user_dst, dst, bp->data + (off % BSIZE), m) == -1) {
    800037a8:	5cfd                	li	s9,-1
    800037aa:	a82d                	j	800037e4 <readi+0x82>
    800037ac:	02091d93          	slli	s11,s2,0x20
    800037b0:	020ddd93          	srli	s11,s11,0x20
    800037b4:	060a8613          	addi	a2,s5,96
    800037b8:	86ee                	mv	a3,s11
    800037ba:	963a                	add	a2,a2,a4
    800037bc:	85d2                	mv	a1,s4
    800037be:	8562                	mv	a0,s8
    800037c0:	fffff097          	auipc	ra,0xfffff
    800037c4:	b14080e7          	jalr	-1260(ra) # 800022d4 <either_copyout>
    800037c8:	05950d63          	beq	a0,s9,80003822 <readi+0xc0>
      brelse(bp);
      break;
    }
    brelse(bp);
    800037cc:	8556                	mv	a0,s5
    800037ce:	fffff097          	auipc	ra,0xfffff
    800037d2:	5fc080e7          	jalr	1532(ra) # 80002dca <brelse>
  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
    800037d6:	013909bb          	addw	s3,s2,s3
    800037da:	009904bb          	addw	s1,s2,s1
    800037de:	9a6e                	add	s4,s4,s11
    800037e0:	0569f663          	bleu	s6,s3,8000382c <readi+0xca>
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    800037e4:	000ba903          	lw	s2,0(s7)
    800037e8:	00a4d59b          	srliw	a1,s1,0xa
    800037ec:	855e                	mv	a0,s7
    800037ee:	00000097          	auipc	ra,0x0
    800037f2:	8d2080e7          	jalr	-1838(ra) # 800030c0 <bmap>
    800037f6:	0005059b          	sext.w	a1,a0
    800037fa:	854a                	mv	a0,s2
    800037fc:	fffff097          	auipc	ra,0xfffff
    80003800:	488080e7          	jalr	1160(ra) # 80002c84 <bread>
    80003804:	8aaa                	mv	s5,a0
    m = min(n - tot, BSIZE - off%BSIZE);
    80003806:	3ff4f713          	andi	a4,s1,1023
    8000380a:	40ed07bb          	subw	a5,s10,a4
    8000380e:	413b06bb          	subw	a3,s6,s3
    80003812:	893e                	mv	s2,a5
    80003814:	2781                	sext.w	a5,a5
    80003816:	0006861b          	sext.w	a2,a3
    8000381a:	f8f679e3          	bleu	a5,a2,800037ac <readi+0x4a>
    8000381e:	8936                	mv	s2,a3
    80003820:	b771                	j	800037ac <readi+0x4a>
      brelse(bp);
    80003822:	8556                	mv	a0,s5
    80003824:	fffff097          	auipc	ra,0xfffff
    80003828:	5a6080e7          	jalr	1446(ra) # 80002dca <brelse>
  }
  return n;
    8000382c:	000b051b          	sext.w	a0,s6
}
    80003830:	70a6                	ld	ra,104(sp)
    80003832:	7406                	ld	s0,96(sp)
    80003834:	64e6                	ld	s1,88(sp)
    80003836:	6946                	ld	s2,80(sp)
    80003838:	69a6                	ld	s3,72(sp)
    8000383a:	6a06                	ld	s4,64(sp)
    8000383c:	7ae2                	ld	s5,56(sp)
    8000383e:	7b42                	ld	s6,48(sp)
    80003840:	7ba2                	ld	s7,40(sp)
    80003842:	7c02                	ld	s8,32(sp)
    80003844:	6ce2                	ld	s9,24(sp)
    80003846:	6d42                	ld	s10,16(sp)
    80003848:	6da2                	ld	s11,8(sp)
    8000384a:	6165                	addi	sp,sp,112
    8000384c:	8082                	ret
    return -1;
    8000384e:	557d                	li	a0,-1
}
    80003850:	8082                	ret
    return -1;
    80003852:	557d                	li	a0,-1
    80003854:	bff1                	j	80003830 <readi+0xce>

0000000080003856 <writei>:
writei(struct inode *ip, int user_src, uint64 src, uint off, uint n)
{
  uint tot, m;
  struct buf *bp;

  if(off > ip->size || off + n < off)
    80003856:	457c                	lw	a5,76(a0)
    80003858:	10d7e763          	bltu	a5,a3,80003966 <writei+0x110>
{
    8000385c:	7159                	addi	sp,sp,-112
    8000385e:	f486                	sd	ra,104(sp)
    80003860:	f0a2                	sd	s0,96(sp)
    80003862:	eca6                	sd	s1,88(sp)
    80003864:	e8ca                	sd	s2,80(sp)
    80003866:	e4ce                	sd	s3,72(sp)
    80003868:	e0d2                	sd	s4,64(sp)
    8000386a:	fc56                	sd	s5,56(sp)
    8000386c:	f85a                	sd	s6,48(sp)
    8000386e:	f45e                	sd	s7,40(sp)
    80003870:	f062                	sd	s8,32(sp)
    80003872:	ec66                	sd	s9,24(sp)
    80003874:	e86a                	sd	s10,16(sp)
    80003876:	e46e                	sd	s11,8(sp)
    80003878:	1880                	addi	s0,sp,112
    8000387a:	8baa                	mv	s7,a0
    8000387c:	8c2e                	mv	s8,a1
    8000387e:	8ab2                	mv	s5,a2
    80003880:	84b6                	mv	s1,a3
    80003882:	8b3a                	mv	s6,a4
  if(off > ip->size || off + n < off)
    80003884:	00e687bb          	addw	a5,a3,a4
    80003888:	0ed7e163          	bltu	a5,a3,8000396a <writei+0x114>
    return -1;
  if(off + n > MAXFILE*BSIZE)
    8000388c:	00043737          	lui	a4,0x43
    80003890:	0cf76f63          	bltu	a4,a5,8000396e <writei+0x118>
    return -1;

  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    80003894:	0a0b0063          	beqz	s6,80003934 <writei+0xde>
    80003898:	4a01                	li	s4,0
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
    8000389a:	40000d13          	li	s10,1024
    if(either_copyin(bp->data + (off % BSIZE), user_src, src, m) == -1) {
    8000389e:	5cfd                	li	s9,-1
    800038a0:	a091                	j	800038e4 <writei+0x8e>
    800038a2:	02091d93          	slli	s11,s2,0x20
    800038a6:	020ddd93          	srli	s11,s11,0x20
    800038aa:	06098513          	addi	a0,s3,96
    800038ae:	86ee                	mv	a3,s11
    800038b0:	8656                	mv	a2,s5
    800038b2:	85e2                	mv	a1,s8
    800038b4:	953a                	add	a0,a0,a4
    800038b6:	fffff097          	auipc	ra,0xfffff
    800038ba:	a74080e7          	jalr	-1420(ra) # 8000232a <either_copyin>
    800038be:	07950263          	beq	a0,s9,80003922 <writei+0xcc>
      brelse(bp);
      break;
    }
    log_write(bp);
    800038c2:	854e                	mv	a0,s3
    800038c4:	00001097          	auipc	ra,0x1
    800038c8:	878080e7          	jalr	-1928(ra) # 8000413c <log_write>
    brelse(bp);
    800038cc:	854e                	mv	a0,s3
    800038ce:	fffff097          	auipc	ra,0xfffff
    800038d2:	4fc080e7          	jalr	1276(ra) # 80002dca <brelse>
  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    800038d6:	01490a3b          	addw	s4,s2,s4
    800038da:	009904bb          	addw	s1,s2,s1
    800038de:	9aee                	add	s5,s5,s11
    800038e0:	056a7663          	bleu	s6,s4,8000392c <writei+0xd6>
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    800038e4:	000ba903          	lw	s2,0(s7)
    800038e8:	00a4d59b          	srliw	a1,s1,0xa
    800038ec:	855e                	mv	a0,s7
    800038ee:	fffff097          	auipc	ra,0xfffff
    800038f2:	7d2080e7          	jalr	2002(ra) # 800030c0 <bmap>
    800038f6:	0005059b          	sext.w	a1,a0
    800038fa:	854a                	mv	a0,s2
    800038fc:	fffff097          	auipc	ra,0xfffff
    80003900:	388080e7          	jalr	904(ra) # 80002c84 <bread>
    80003904:	89aa                	mv	s3,a0
    m = min(n - tot, BSIZE - off%BSIZE);
    80003906:	3ff4f713          	andi	a4,s1,1023
    8000390a:	40ed07bb          	subw	a5,s10,a4
    8000390e:	414b06bb          	subw	a3,s6,s4
    80003912:	893e                	mv	s2,a5
    80003914:	2781                	sext.w	a5,a5
    80003916:	0006861b          	sext.w	a2,a3
    8000391a:	f8f674e3          	bleu	a5,a2,800038a2 <writei+0x4c>
    8000391e:	8936                	mv	s2,a3
    80003920:	b749                	j	800038a2 <writei+0x4c>
      brelse(bp);
    80003922:	854e                	mv	a0,s3
    80003924:	fffff097          	auipc	ra,0xfffff
    80003928:	4a6080e7          	jalr	1190(ra) # 80002dca <brelse>
  }

  if(n > 0 && off > ip->size){
    8000392c:	04cba783          	lw	a5,76(s7)
    80003930:	0297e363          	bltu	a5,s1,80003956 <writei+0x100>
    ip->size = off;
    iupdate(ip);
  }
  return n;
    80003934:	000b051b          	sext.w	a0,s6
}
    80003938:	70a6                	ld	ra,104(sp)
    8000393a:	7406                	ld	s0,96(sp)
    8000393c:	64e6                	ld	s1,88(sp)
    8000393e:	6946                	ld	s2,80(sp)
    80003940:	69a6                	ld	s3,72(sp)
    80003942:	6a06                	ld	s4,64(sp)
    80003944:	7ae2                	ld	s5,56(sp)
    80003946:	7b42                	ld	s6,48(sp)
    80003948:	7ba2                	ld	s7,40(sp)
    8000394a:	7c02                	ld	s8,32(sp)
    8000394c:	6ce2                	ld	s9,24(sp)
    8000394e:	6d42                	ld	s10,16(sp)
    80003950:	6da2                	ld	s11,8(sp)
    80003952:	6165                	addi	sp,sp,112
    80003954:	8082                	ret
    ip->size = off;
    80003956:	049ba623          	sw	s1,76(s7)
    iupdate(ip);
    8000395a:	855e                	mv	a0,s7
    8000395c:	00000097          	auipc	ra,0x0
    80003960:	aa8080e7          	jalr	-1368(ra) # 80003404 <iupdate>
    80003964:	bfc1                	j	80003934 <writei+0xde>
    return -1;
    80003966:	557d                	li	a0,-1
}
    80003968:	8082                	ret
    return -1;
    8000396a:	557d                	li	a0,-1
    8000396c:	b7f1                	j	80003938 <writei+0xe2>
    return -1;
    8000396e:	557d                	li	a0,-1
    80003970:	b7e1                	j	80003938 <writei+0xe2>

0000000080003972 <namecmp>:

// Directories

int
namecmp(const char *s, const char *t)
{
    80003972:	1141                	addi	sp,sp,-16
    80003974:	e406                	sd	ra,8(sp)
    80003976:	e022                	sd	s0,0(sp)
    80003978:	0800                	addi	s0,sp,16
  return strncmp(s, t, DIRSIZ);
    8000397a:	4639                	li	a2,14
    8000397c:	ffffd097          	auipc	ra,0xffffd
    80003980:	332080e7          	jalr	818(ra) # 80000cae <strncmp>
}
    80003984:	60a2                	ld	ra,8(sp)
    80003986:	6402                	ld	s0,0(sp)
    80003988:	0141                	addi	sp,sp,16
    8000398a:	8082                	ret

000000008000398c <dirlookup>:

// Look for a directory entry in a directory.
// If found, set *poff to byte offset of entry.
struct inode*
dirlookup(struct inode *dp, char *name, uint *poff)
{
    8000398c:	7139                	addi	sp,sp,-64
    8000398e:	fc06                	sd	ra,56(sp)
    80003990:	f822                	sd	s0,48(sp)
    80003992:	f426                	sd	s1,40(sp)
    80003994:	f04a                	sd	s2,32(sp)
    80003996:	ec4e                	sd	s3,24(sp)
    80003998:	e852                	sd	s4,16(sp)
    8000399a:	0080                	addi	s0,sp,64
  uint off, inum;
  struct dirent de;

  if(dp->type != T_DIR)
    8000399c:	04451703          	lh	a4,68(a0)
    800039a0:	4785                	li	a5,1
    800039a2:	00f71a63          	bne	a4,a5,800039b6 <dirlookup+0x2a>
    800039a6:	892a                	mv	s2,a0
    800039a8:	89ae                	mv	s3,a1
    800039aa:	8a32                	mv	s4,a2
    panic("dirlookup not DIR");

  for(off = 0; off < dp->size; off += sizeof(de)){
    800039ac:	457c                	lw	a5,76(a0)
    800039ae:	4481                	li	s1,0
      inum = de.inum;
      return iget(dp->dev, inum);
    }
  }

  return 0;
    800039b0:	4501                	li	a0,0
  for(off = 0; off < dp->size; off += sizeof(de)){
    800039b2:	e79d                	bnez	a5,800039e0 <dirlookup+0x54>
    800039b4:	a8a5                	j	80003a2c <dirlookup+0xa0>
    panic("dirlookup not DIR");
    800039b6:	00004517          	auipc	a0,0x4
    800039ba:	c1a50513          	addi	a0,a0,-998 # 800075d0 <userret+0x540>
    800039be:	ffffd097          	auipc	ra,0xffffd
    800039c2:	bc0080e7          	jalr	-1088(ra) # 8000057e <panic>
      panic("dirlookup read");
    800039c6:	00004517          	auipc	a0,0x4
    800039ca:	c2250513          	addi	a0,a0,-990 # 800075e8 <userret+0x558>
    800039ce:	ffffd097          	auipc	ra,0xffffd
    800039d2:	bb0080e7          	jalr	-1104(ra) # 8000057e <panic>
  for(off = 0; off < dp->size; off += sizeof(de)){
    800039d6:	24c1                	addiw	s1,s1,16
    800039d8:	04c92783          	lw	a5,76(s2)
    800039dc:	04f4f763          	bleu	a5,s1,80003a2a <dirlookup+0x9e>
    if(readi(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    800039e0:	4741                	li	a4,16
    800039e2:	86a6                	mv	a3,s1
    800039e4:	fc040613          	addi	a2,s0,-64
    800039e8:	4581                	li	a1,0
    800039ea:	854a                	mv	a0,s2
    800039ec:	00000097          	auipc	ra,0x0
    800039f0:	d76080e7          	jalr	-650(ra) # 80003762 <readi>
    800039f4:	47c1                	li	a5,16
    800039f6:	fcf518e3          	bne	a0,a5,800039c6 <dirlookup+0x3a>
    if(de.inum == 0)
    800039fa:	fc045783          	lhu	a5,-64(s0)
    800039fe:	dfe1                	beqz	a5,800039d6 <dirlookup+0x4a>
    if(namecmp(name, de.name) == 0){
    80003a00:	fc240593          	addi	a1,s0,-62
    80003a04:	854e                	mv	a0,s3
    80003a06:	00000097          	auipc	ra,0x0
    80003a0a:	f6c080e7          	jalr	-148(ra) # 80003972 <namecmp>
    80003a0e:	f561                	bnez	a0,800039d6 <dirlookup+0x4a>
      if(poff)
    80003a10:	000a0463          	beqz	s4,80003a18 <dirlookup+0x8c>
        *poff = off;
    80003a14:	009a2023          	sw	s1,0(s4) # 2000 <_entry-0x7fffe000>
      return iget(dp->dev, inum);
    80003a18:	fc045583          	lhu	a1,-64(s0)
    80003a1c:	00092503          	lw	a0,0(s2)
    80003a20:	fffff097          	auipc	ra,0xfffff
    80003a24:	77a080e7          	jalr	1914(ra) # 8000319a <iget>
    80003a28:	a011                	j	80003a2c <dirlookup+0xa0>
  return 0;
    80003a2a:	4501                	li	a0,0
}
    80003a2c:	70e2                	ld	ra,56(sp)
    80003a2e:	7442                	ld	s0,48(sp)
    80003a30:	74a2                	ld	s1,40(sp)
    80003a32:	7902                	ld	s2,32(sp)
    80003a34:	69e2                	ld	s3,24(sp)
    80003a36:	6a42                	ld	s4,16(sp)
    80003a38:	6121                	addi	sp,sp,64
    80003a3a:	8082                	ret

0000000080003a3c <namex>:
// If parent != 0, return the inode for the parent and copy the final
// path element into name, which must have room for DIRSIZ bytes.
// Must be called inside a transaction since it calls iput().
static struct inode*
namex(char *path, int nameiparent, char *name)
{
    80003a3c:	711d                	addi	sp,sp,-96
    80003a3e:	ec86                	sd	ra,88(sp)
    80003a40:	e8a2                	sd	s0,80(sp)
    80003a42:	e4a6                	sd	s1,72(sp)
    80003a44:	e0ca                	sd	s2,64(sp)
    80003a46:	fc4e                	sd	s3,56(sp)
    80003a48:	f852                	sd	s4,48(sp)
    80003a4a:	f456                	sd	s5,40(sp)
    80003a4c:	f05a                	sd	s6,32(sp)
    80003a4e:	ec5e                	sd	s7,24(sp)
    80003a50:	e862                	sd	s8,16(sp)
    80003a52:	e466                	sd	s9,8(sp)
    80003a54:	1080                	addi	s0,sp,96
    80003a56:	84aa                	mv	s1,a0
    80003a58:	8bae                	mv	s7,a1
    80003a5a:	8ab2                	mv	s5,a2
  struct inode *ip, *next;

  if(*path == '/')
    80003a5c:	00054703          	lbu	a4,0(a0)
    80003a60:	02f00793          	li	a5,47
    80003a64:	02f70363          	beq	a4,a5,80003a8a <namex+0x4e>
    ip = iget(ROOTDEV, ROOTINO);
  else
    ip = idup(myproc()->cwd);
    80003a68:	ffffe097          	auipc	ra,0xffffe
    80003a6c:	e36080e7          	jalr	-458(ra) # 8000189e <myproc>
    80003a70:	14853503          	ld	a0,328(a0)
    80003a74:	00000097          	auipc	ra,0x0
    80003a78:	a1e080e7          	jalr	-1506(ra) # 80003492 <idup>
    80003a7c:	89aa                	mv	s3,a0
  while(*path == '/')
    80003a7e:	02f00913          	li	s2,47
  len = path - s;
    80003a82:	4b01                	li	s6,0
  if(len >= DIRSIZ)
    80003a84:	4cb5                	li	s9,13

  while((path = skipelem(path, name)) != 0){
    ilock(ip);
    if(ip->type != T_DIR){
    80003a86:	4c05                	li	s8,1
    80003a88:	a865                	j	80003b40 <namex+0x104>
    ip = iget(ROOTDEV, ROOTINO);
    80003a8a:	4585                	li	a1,1
    80003a8c:	4501                	li	a0,0
    80003a8e:	fffff097          	auipc	ra,0xfffff
    80003a92:	70c080e7          	jalr	1804(ra) # 8000319a <iget>
    80003a96:	89aa                	mv	s3,a0
    80003a98:	b7dd                	j	80003a7e <namex+0x42>
      iunlockput(ip);
    80003a9a:	854e                	mv	a0,s3
    80003a9c:	00000097          	auipc	ra,0x0
    80003aa0:	c74080e7          	jalr	-908(ra) # 80003710 <iunlockput>
      return 0;
    80003aa4:	4981                	li	s3,0
  if(nameiparent){
    iput(ip);
    return 0;
  }
  return ip;
}
    80003aa6:	854e                	mv	a0,s3
    80003aa8:	60e6                	ld	ra,88(sp)
    80003aaa:	6446                	ld	s0,80(sp)
    80003aac:	64a6                	ld	s1,72(sp)
    80003aae:	6906                	ld	s2,64(sp)
    80003ab0:	79e2                	ld	s3,56(sp)
    80003ab2:	7a42                	ld	s4,48(sp)
    80003ab4:	7aa2                	ld	s5,40(sp)
    80003ab6:	7b02                	ld	s6,32(sp)
    80003ab8:	6be2                	ld	s7,24(sp)
    80003aba:	6c42                	ld	s8,16(sp)
    80003abc:	6ca2                	ld	s9,8(sp)
    80003abe:	6125                	addi	sp,sp,96
    80003ac0:	8082                	ret
      iunlock(ip);
    80003ac2:	854e                	mv	a0,s3
    80003ac4:	00000097          	auipc	ra,0x0
    80003ac8:	ad0080e7          	jalr	-1328(ra) # 80003594 <iunlock>
      return ip;
    80003acc:	bfe9                	j	80003aa6 <namex+0x6a>
      iunlockput(ip);
    80003ace:	854e                	mv	a0,s3
    80003ad0:	00000097          	auipc	ra,0x0
    80003ad4:	c40080e7          	jalr	-960(ra) # 80003710 <iunlockput>
      return 0;
    80003ad8:	89d2                	mv	s3,s4
    80003ada:	b7f1                	j	80003aa6 <namex+0x6a>
  len = path - s;
    80003adc:	40b48633          	sub	a2,s1,a1
    80003ae0:	00060a1b          	sext.w	s4,a2
  if(len >= DIRSIZ)
    80003ae4:	094cd663          	ble	s4,s9,80003b70 <namex+0x134>
    memmove(name, s, DIRSIZ);
    80003ae8:	4639                	li	a2,14
    80003aea:	8556                	mv	a0,s5
    80003aec:	ffffd097          	auipc	ra,0xffffd
    80003af0:	146080e7          	jalr	326(ra) # 80000c32 <memmove>
  while(*path == '/')
    80003af4:	0004c783          	lbu	a5,0(s1)
    80003af8:	01279763          	bne	a5,s2,80003b06 <namex+0xca>
    path++;
    80003afc:	0485                	addi	s1,s1,1
  while(*path == '/')
    80003afe:	0004c783          	lbu	a5,0(s1)
    80003b02:	ff278de3          	beq	a5,s2,80003afc <namex+0xc0>
    ilock(ip);
    80003b06:	854e                	mv	a0,s3
    80003b08:	00000097          	auipc	ra,0x0
    80003b0c:	9c8080e7          	jalr	-1592(ra) # 800034d0 <ilock>
    if(ip->type != T_DIR){
    80003b10:	04499783          	lh	a5,68(s3)
    80003b14:	f98793e3          	bne	a5,s8,80003a9a <namex+0x5e>
    if(nameiparent && *path == '\0'){
    80003b18:	000b8563          	beqz	s7,80003b22 <namex+0xe6>
    80003b1c:	0004c783          	lbu	a5,0(s1)
    80003b20:	d3cd                	beqz	a5,80003ac2 <namex+0x86>
    if((next = dirlookup(ip, name, 0)) == 0){
    80003b22:	865a                	mv	a2,s6
    80003b24:	85d6                	mv	a1,s5
    80003b26:	854e                	mv	a0,s3
    80003b28:	00000097          	auipc	ra,0x0
    80003b2c:	e64080e7          	jalr	-412(ra) # 8000398c <dirlookup>
    80003b30:	8a2a                	mv	s4,a0
    80003b32:	dd51                	beqz	a0,80003ace <namex+0x92>
    iunlockput(ip);
    80003b34:	854e                	mv	a0,s3
    80003b36:	00000097          	auipc	ra,0x0
    80003b3a:	bda080e7          	jalr	-1062(ra) # 80003710 <iunlockput>
    ip = next;
    80003b3e:	89d2                	mv	s3,s4
  while(*path == '/')
    80003b40:	0004c783          	lbu	a5,0(s1)
    80003b44:	05279d63          	bne	a5,s2,80003b9e <namex+0x162>
    path++;
    80003b48:	0485                	addi	s1,s1,1
  while(*path == '/')
    80003b4a:	0004c783          	lbu	a5,0(s1)
    80003b4e:	ff278de3          	beq	a5,s2,80003b48 <namex+0x10c>
  if(*path == 0)
    80003b52:	cf8d                	beqz	a5,80003b8c <namex+0x150>
  while(*path != '/' && *path != 0)
    80003b54:	01278b63          	beq	a5,s2,80003b6a <namex+0x12e>
    80003b58:	c795                	beqz	a5,80003b84 <namex+0x148>
    path++;
    80003b5a:	85a6                	mv	a1,s1
    path++;
    80003b5c:	0485                	addi	s1,s1,1
  while(*path != '/' && *path != 0)
    80003b5e:	0004c783          	lbu	a5,0(s1)
    80003b62:	f7278de3          	beq	a5,s2,80003adc <namex+0xa0>
    80003b66:	fbfd                	bnez	a5,80003b5c <namex+0x120>
    80003b68:	bf95                	j	80003adc <namex+0xa0>
    80003b6a:	85a6                	mv	a1,s1
  len = path - s;
    80003b6c:	8a5a                	mv	s4,s6
    80003b6e:	865a                	mv	a2,s6
    memmove(name, s, len);
    80003b70:	2601                	sext.w	a2,a2
    80003b72:	8556                	mv	a0,s5
    80003b74:	ffffd097          	auipc	ra,0xffffd
    80003b78:	0be080e7          	jalr	190(ra) # 80000c32 <memmove>
    name[len] = 0;
    80003b7c:	9a56                	add	s4,s4,s5
    80003b7e:	000a0023          	sb	zero,0(s4)
    80003b82:	bf8d                	j	80003af4 <namex+0xb8>
  while(*path != '/' && *path != 0)
    80003b84:	85a6                	mv	a1,s1
  len = path - s;
    80003b86:	8a5a                	mv	s4,s6
    80003b88:	865a                	mv	a2,s6
    80003b8a:	b7dd                	j	80003b70 <namex+0x134>
  if(nameiparent){
    80003b8c:	f00b8de3          	beqz	s7,80003aa6 <namex+0x6a>
    iput(ip);
    80003b90:	854e                	mv	a0,s3
    80003b92:	00000097          	auipc	ra,0x0
    80003b96:	a4e080e7          	jalr	-1458(ra) # 800035e0 <iput>
    return 0;
    80003b9a:	4981                	li	s3,0
    80003b9c:	b729                	j	80003aa6 <namex+0x6a>
  if(*path == 0)
    80003b9e:	d7fd                	beqz	a5,80003b8c <namex+0x150>
    80003ba0:	85a6                	mv	a1,s1
    80003ba2:	bf6d                	j	80003b5c <namex+0x120>

0000000080003ba4 <dirlink>:
{
    80003ba4:	7139                	addi	sp,sp,-64
    80003ba6:	fc06                	sd	ra,56(sp)
    80003ba8:	f822                	sd	s0,48(sp)
    80003baa:	f426                	sd	s1,40(sp)
    80003bac:	f04a                	sd	s2,32(sp)
    80003bae:	ec4e                	sd	s3,24(sp)
    80003bb0:	e852                	sd	s4,16(sp)
    80003bb2:	0080                	addi	s0,sp,64
    80003bb4:	892a                	mv	s2,a0
    80003bb6:	8a2e                	mv	s4,a1
    80003bb8:	89b2                	mv	s3,a2
  if((ip = dirlookup(dp, name, 0)) != 0){
    80003bba:	4601                	li	a2,0
    80003bbc:	00000097          	auipc	ra,0x0
    80003bc0:	dd0080e7          	jalr	-560(ra) # 8000398c <dirlookup>
    80003bc4:	e93d                	bnez	a0,80003c3a <dirlink+0x96>
  for(off = 0; off < dp->size; off += sizeof(de)){
    80003bc6:	04c92483          	lw	s1,76(s2)
    80003bca:	c49d                	beqz	s1,80003bf8 <dirlink+0x54>
    80003bcc:	4481                	li	s1,0
    if(readi(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80003bce:	4741                	li	a4,16
    80003bd0:	86a6                	mv	a3,s1
    80003bd2:	fc040613          	addi	a2,s0,-64
    80003bd6:	4581                	li	a1,0
    80003bd8:	854a                	mv	a0,s2
    80003bda:	00000097          	auipc	ra,0x0
    80003bde:	b88080e7          	jalr	-1144(ra) # 80003762 <readi>
    80003be2:	47c1                	li	a5,16
    80003be4:	06f51163          	bne	a0,a5,80003c46 <dirlink+0xa2>
    if(de.inum == 0)
    80003be8:	fc045783          	lhu	a5,-64(s0)
    80003bec:	c791                	beqz	a5,80003bf8 <dirlink+0x54>
  for(off = 0; off < dp->size; off += sizeof(de)){
    80003bee:	24c1                	addiw	s1,s1,16
    80003bf0:	04c92783          	lw	a5,76(s2)
    80003bf4:	fcf4ede3          	bltu	s1,a5,80003bce <dirlink+0x2a>
  strncpy(de.name, name, DIRSIZ);
    80003bf8:	4639                	li	a2,14
    80003bfa:	85d2                	mv	a1,s4
    80003bfc:	fc240513          	addi	a0,s0,-62
    80003c00:	ffffd097          	auipc	ra,0xffffd
    80003c04:	0fe080e7          	jalr	254(ra) # 80000cfe <strncpy>
  de.inum = inum;
    80003c08:	fd341023          	sh	s3,-64(s0)
  if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80003c0c:	4741                	li	a4,16
    80003c0e:	86a6                	mv	a3,s1
    80003c10:	fc040613          	addi	a2,s0,-64
    80003c14:	4581                	li	a1,0
    80003c16:	854a                	mv	a0,s2
    80003c18:	00000097          	auipc	ra,0x0
    80003c1c:	c3e080e7          	jalr	-962(ra) # 80003856 <writei>
    80003c20:	4741                	li	a4,16
  return 0;
    80003c22:	4781                	li	a5,0
  if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80003c24:	02e51963          	bne	a0,a4,80003c56 <dirlink+0xb2>
}
    80003c28:	853e                	mv	a0,a5
    80003c2a:	70e2                	ld	ra,56(sp)
    80003c2c:	7442                	ld	s0,48(sp)
    80003c2e:	74a2                	ld	s1,40(sp)
    80003c30:	7902                	ld	s2,32(sp)
    80003c32:	69e2                	ld	s3,24(sp)
    80003c34:	6a42                	ld	s4,16(sp)
    80003c36:	6121                	addi	sp,sp,64
    80003c38:	8082                	ret
    iput(ip);
    80003c3a:	00000097          	auipc	ra,0x0
    80003c3e:	9a6080e7          	jalr	-1626(ra) # 800035e0 <iput>
    return -1;
    80003c42:	57fd                	li	a5,-1
    80003c44:	b7d5                	j	80003c28 <dirlink+0x84>
      panic("dirlink read");
    80003c46:	00004517          	auipc	a0,0x4
    80003c4a:	9b250513          	addi	a0,a0,-1614 # 800075f8 <userret+0x568>
    80003c4e:	ffffd097          	auipc	ra,0xffffd
    80003c52:	930080e7          	jalr	-1744(ra) # 8000057e <panic>
    panic("dirlink");
    80003c56:	00004517          	auipc	a0,0x4
    80003c5a:	b5250513          	addi	a0,a0,-1198 # 800077a8 <userret+0x718>
    80003c5e:	ffffd097          	auipc	ra,0xffffd
    80003c62:	920080e7          	jalr	-1760(ra) # 8000057e <panic>

0000000080003c66 <namei>:

struct inode*
namei(char *path)
{
    80003c66:	1101                	addi	sp,sp,-32
    80003c68:	ec06                	sd	ra,24(sp)
    80003c6a:	e822                	sd	s0,16(sp)
    80003c6c:	1000                	addi	s0,sp,32
  char name[DIRSIZ];
  return namex(path, 0, name);
    80003c6e:	fe040613          	addi	a2,s0,-32
    80003c72:	4581                	li	a1,0
    80003c74:	00000097          	auipc	ra,0x0
    80003c78:	dc8080e7          	jalr	-568(ra) # 80003a3c <namex>
}
    80003c7c:	60e2                	ld	ra,24(sp)
    80003c7e:	6442                	ld	s0,16(sp)
    80003c80:	6105                	addi	sp,sp,32
    80003c82:	8082                	ret

0000000080003c84 <nameiparent>:

struct inode*
nameiparent(char *path, char *name)
{
    80003c84:	1141                	addi	sp,sp,-16
    80003c86:	e406                	sd	ra,8(sp)
    80003c88:	e022                	sd	s0,0(sp)
    80003c8a:	0800                	addi	s0,sp,16
  return namex(path, 1, name);
    80003c8c:	862e                	mv	a2,a1
    80003c8e:	4585                	li	a1,1
    80003c90:	00000097          	auipc	ra,0x0
    80003c94:	dac080e7          	jalr	-596(ra) # 80003a3c <namex>
}
    80003c98:	60a2                	ld	ra,8(sp)
    80003c9a:	6402                	ld	s0,0(sp)
    80003c9c:	0141                	addi	sp,sp,16
    80003c9e:	8082                	ret

0000000080003ca0 <write_head>:
// Write in-memory log header to disk.
// This is the true point at which the
// current transaction commits.
static void
write_head(int dev)
{
    80003ca0:	7179                	addi	sp,sp,-48
    80003ca2:	f406                	sd	ra,40(sp)
    80003ca4:	f022                	sd	s0,32(sp)
    80003ca6:	ec26                	sd	s1,24(sp)
    80003ca8:	e84a                	sd	s2,16(sp)
    80003caa:	e44e                	sd	s3,8(sp)
    80003cac:	1800                	addi	s0,sp,48
    80003cae:	84aa                	mv	s1,a0
  struct buf *buf = bread(dev, log[dev].start);
    80003cb0:	0a800993          	li	s3,168
    80003cb4:	033507b3          	mul	a5,a0,s3
    80003cb8:	0001e997          	auipc	s3,0x1e
    80003cbc:	ae098993          	addi	s3,s3,-1312 # 80021798 <log>
    80003cc0:	99be                	add	s3,s3,a5
    80003cc2:	0189a583          	lw	a1,24(s3)
    80003cc6:	fffff097          	auipc	ra,0xfffff
    80003cca:	fbe080e7          	jalr	-66(ra) # 80002c84 <bread>
    80003cce:	892a                	mv	s2,a0
  struct logheader *hb = (struct logheader *) (buf->data);
  int i;
  hb->n = log[dev].lh.n;
    80003cd0:	02c9a783          	lw	a5,44(s3)
    80003cd4:	d13c                	sw	a5,96(a0)
  for (i = 0; i < log[dev].lh.n; i++) {
    80003cd6:	02c9a783          	lw	a5,44(s3)
    80003cda:	02f05763          	blez	a5,80003d08 <write_head+0x68>
    80003cde:	0a800793          	li	a5,168
    80003ce2:	02f487b3          	mul	a5,s1,a5
    80003ce6:	0001e717          	auipc	a4,0x1e
    80003cea:	ae270713          	addi	a4,a4,-1310 # 800217c8 <log+0x30>
    80003cee:	97ba                	add	a5,a5,a4
    80003cf0:	06450693          	addi	a3,a0,100
    80003cf4:	4701                	li	a4,0
    80003cf6:	85ce                	mv	a1,s3
    hb->block[i] = log[dev].lh.block[i];
    80003cf8:	4390                	lw	a2,0(a5)
    80003cfa:	c290                	sw	a2,0(a3)
  for (i = 0; i < log[dev].lh.n; i++) {
    80003cfc:	2705                	addiw	a4,a4,1
    80003cfe:	0791                	addi	a5,a5,4
    80003d00:	0691                	addi	a3,a3,4
    80003d02:	55d0                	lw	a2,44(a1)
    80003d04:	fec74ae3          	blt	a4,a2,80003cf8 <write_head+0x58>
  }
  bwrite(buf);
    80003d08:	854a                	mv	a0,s2
    80003d0a:	fffff097          	auipc	ra,0xfffff
    80003d0e:	080080e7          	jalr	128(ra) # 80002d8a <bwrite>
  brelse(buf);
    80003d12:	854a                	mv	a0,s2
    80003d14:	fffff097          	auipc	ra,0xfffff
    80003d18:	0b6080e7          	jalr	182(ra) # 80002dca <brelse>
}
    80003d1c:	70a2                	ld	ra,40(sp)
    80003d1e:	7402                	ld	s0,32(sp)
    80003d20:	64e2                	ld	s1,24(sp)
    80003d22:	6942                	ld	s2,16(sp)
    80003d24:	69a2                	ld	s3,8(sp)
    80003d26:	6145                	addi	sp,sp,48
    80003d28:	8082                	ret

0000000080003d2a <write_log>:
static void
write_log(int dev)
{
  int tail;

  for (tail = 0; tail < log[dev].lh.n; tail++) {
    80003d2a:	0a800793          	li	a5,168
    80003d2e:	02f50733          	mul	a4,a0,a5
    80003d32:	0001e797          	auipc	a5,0x1e
    80003d36:	a6678793          	addi	a5,a5,-1434 # 80021798 <log>
    80003d3a:	97ba                	add	a5,a5,a4
    80003d3c:	57dc                	lw	a5,44(a5)
    80003d3e:	0af05563          	blez	a5,80003de8 <write_log+0xbe>
{
    80003d42:	7139                	addi	sp,sp,-64
    80003d44:	fc06                	sd	ra,56(sp)
    80003d46:	f822                	sd	s0,48(sp)
    80003d48:	f426                	sd	s1,40(sp)
    80003d4a:	f04a                	sd	s2,32(sp)
    80003d4c:	ec4e                	sd	s3,24(sp)
    80003d4e:	e852                	sd	s4,16(sp)
    80003d50:	e456                	sd	s5,8(sp)
    80003d52:	e05a                	sd	s6,0(sp)
    80003d54:	0080                	addi	s0,sp,64
    80003d56:	0001e797          	auipc	a5,0x1e
    80003d5a:	a7278793          	addi	a5,a5,-1422 # 800217c8 <log+0x30>
    80003d5e:	00f709b3          	add	s3,a4,a5
  for (tail = 0; tail < log[dev].lh.n; tail++) {
    80003d62:	4481                	li	s1,0
    struct buf *to = bread(dev, log[dev].start+tail+1); // log block
    80003d64:	00050b1b          	sext.w	s6,a0
    80003d68:	0001ea97          	auipc	s5,0x1e
    80003d6c:	a30a8a93          	addi	s5,s5,-1488 # 80021798 <log>
    80003d70:	9aba                	add	s5,s5,a4
    80003d72:	018aa583          	lw	a1,24(s5)
    80003d76:	9da5                	addw	a1,a1,s1
    80003d78:	2585                	addiw	a1,a1,1
    80003d7a:	855a                	mv	a0,s6
    80003d7c:	fffff097          	auipc	ra,0xfffff
    80003d80:	f08080e7          	jalr	-248(ra) # 80002c84 <bread>
    80003d84:	892a                	mv	s2,a0
    struct buf *from = bread(dev, log[dev].lh.block[tail]); // cache block
    80003d86:	0009a583          	lw	a1,0(s3)
    80003d8a:	855a                	mv	a0,s6
    80003d8c:	fffff097          	auipc	ra,0xfffff
    80003d90:	ef8080e7          	jalr	-264(ra) # 80002c84 <bread>
    80003d94:	8a2a                	mv	s4,a0
    memmove(to->data, from->data, BSIZE);
    80003d96:	40000613          	li	a2,1024
    80003d9a:	06050593          	addi	a1,a0,96
    80003d9e:	06090513          	addi	a0,s2,96
    80003da2:	ffffd097          	auipc	ra,0xffffd
    80003da6:	e90080e7          	jalr	-368(ra) # 80000c32 <memmove>
    bwrite(to);  // write the log
    80003daa:	854a                	mv	a0,s2
    80003dac:	fffff097          	auipc	ra,0xfffff
    80003db0:	fde080e7          	jalr	-34(ra) # 80002d8a <bwrite>
    brelse(from);
    80003db4:	8552                	mv	a0,s4
    80003db6:	fffff097          	auipc	ra,0xfffff
    80003dba:	014080e7          	jalr	20(ra) # 80002dca <brelse>
    brelse(to);
    80003dbe:	854a                	mv	a0,s2
    80003dc0:	fffff097          	auipc	ra,0xfffff
    80003dc4:	00a080e7          	jalr	10(ra) # 80002dca <brelse>
  for (tail = 0; tail < log[dev].lh.n; tail++) {
    80003dc8:	2485                	addiw	s1,s1,1
    80003dca:	0991                	addi	s3,s3,4
    80003dcc:	02caa783          	lw	a5,44(s5)
    80003dd0:	faf4c1e3          	blt	s1,a5,80003d72 <write_log+0x48>
  }
}
    80003dd4:	70e2                	ld	ra,56(sp)
    80003dd6:	7442                	ld	s0,48(sp)
    80003dd8:	74a2                	ld	s1,40(sp)
    80003dda:	7902                	ld	s2,32(sp)
    80003ddc:	69e2                	ld	s3,24(sp)
    80003dde:	6a42                	ld	s4,16(sp)
    80003de0:	6aa2                	ld	s5,8(sp)
    80003de2:	6b02                	ld	s6,0(sp)
    80003de4:	6121                	addi	sp,sp,64
    80003de6:	8082                	ret
    80003de8:	8082                	ret

0000000080003dea <install_trans>:
  for (tail = 0; tail < log[dev].lh.n; tail++) {
    80003dea:	0a800793          	li	a5,168
    80003dee:	02f50733          	mul	a4,a0,a5
    80003df2:	0001e797          	auipc	a5,0x1e
    80003df6:	9a678793          	addi	a5,a5,-1626 # 80021798 <log>
    80003dfa:	97ba                	add	a5,a5,a4
    80003dfc:	57dc                	lw	a5,44(a5)
    80003dfe:	0af05b63          	blez	a5,80003eb4 <install_trans+0xca>
{
    80003e02:	7139                	addi	sp,sp,-64
    80003e04:	fc06                	sd	ra,56(sp)
    80003e06:	f822                	sd	s0,48(sp)
    80003e08:	f426                	sd	s1,40(sp)
    80003e0a:	f04a                	sd	s2,32(sp)
    80003e0c:	ec4e                	sd	s3,24(sp)
    80003e0e:	e852                	sd	s4,16(sp)
    80003e10:	e456                	sd	s5,8(sp)
    80003e12:	e05a                	sd	s6,0(sp)
    80003e14:	0080                	addi	s0,sp,64
    80003e16:	0001e797          	auipc	a5,0x1e
    80003e1a:	9b278793          	addi	a5,a5,-1614 # 800217c8 <log+0x30>
    80003e1e:	00f709b3          	add	s3,a4,a5
  for (tail = 0; tail < log[dev].lh.n; tail++) {
    80003e22:	4901                	li	s2,0
    struct buf *lbuf = bread(dev, log[dev].start+tail+1); // read log block
    80003e24:	00050b1b          	sext.w	s6,a0
    80003e28:	0001ea97          	auipc	s5,0x1e
    80003e2c:	970a8a93          	addi	s5,s5,-1680 # 80021798 <log>
    80003e30:	9aba                	add	s5,s5,a4
    80003e32:	018aa583          	lw	a1,24(s5)
    80003e36:	012585bb          	addw	a1,a1,s2
    80003e3a:	2585                	addiw	a1,a1,1
    80003e3c:	855a                	mv	a0,s6
    80003e3e:	fffff097          	auipc	ra,0xfffff
    80003e42:	e46080e7          	jalr	-442(ra) # 80002c84 <bread>
    80003e46:	8a2a                	mv	s4,a0
    struct buf *dbuf = bread(dev, log[dev].lh.block[tail]); // read dst
    80003e48:	0009a583          	lw	a1,0(s3)
    80003e4c:	855a                	mv	a0,s6
    80003e4e:	fffff097          	auipc	ra,0xfffff
    80003e52:	e36080e7          	jalr	-458(ra) # 80002c84 <bread>
    80003e56:	84aa                	mv	s1,a0
    memmove(dbuf->data, lbuf->data, BSIZE);  // copy block to dst
    80003e58:	40000613          	li	a2,1024
    80003e5c:	060a0593          	addi	a1,s4,96
    80003e60:	06050513          	addi	a0,a0,96
    80003e64:	ffffd097          	auipc	ra,0xffffd
    80003e68:	dce080e7          	jalr	-562(ra) # 80000c32 <memmove>
    bwrite(dbuf);  // write dst to disk
    80003e6c:	8526                	mv	a0,s1
    80003e6e:	fffff097          	auipc	ra,0xfffff
    80003e72:	f1c080e7          	jalr	-228(ra) # 80002d8a <bwrite>
    bunpin(dbuf);
    80003e76:	8526                	mv	a0,s1
    80003e78:	fffff097          	auipc	ra,0xfffff
    80003e7c:	02c080e7          	jalr	44(ra) # 80002ea4 <bunpin>
    brelse(lbuf);
    80003e80:	8552                	mv	a0,s4
    80003e82:	fffff097          	auipc	ra,0xfffff
    80003e86:	f48080e7          	jalr	-184(ra) # 80002dca <brelse>
    brelse(dbuf);
    80003e8a:	8526                	mv	a0,s1
    80003e8c:	fffff097          	auipc	ra,0xfffff
    80003e90:	f3e080e7          	jalr	-194(ra) # 80002dca <brelse>
  for (tail = 0; tail < log[dev].lh.n; tail++) {
    80003e94:	2905                	addiw	s2,s2,1
    80003e96:	0991                	addi	s3,s3,4
    80003e98:	02caa783          	lw	a5,44(s5)
    80003e9c:	f8f94be3          	blt	s2,a5,80003e32 <install_trans+0x48>
}
    80003ea0:	70e2                	ld	ra,56(sp)
    80003ea2:	7442                	ld	s0,48(sp)
    80003ea4:	74a2                	ld	s1,40(sp)
    80003ea6:	7902                	ld	s2,32(sp)
    80003ea8:	69e2                	ld	s3,24(sp)
    80003eaa:	6a42                	ld	s4,16(sp)
    80003eac:	6aa2                	ld	s5,8(sp)
    80003eae:	6b02                	ld	s6,0(sp)
    80003eb0:	6121                	addi	sp,sp,64
    80003eb2:	8082                	ret
    80003eb4:	8082                	ret

0000000080003eb6 <initlog>:
{
    80003eb6:	7179                	addi	sp,sp,-48
    80003eb8:	f406                	sd	ra,40(sp)
    80003eba:	f022                	sd	s0,32(sp)
    80003ebc:	ec26                	sd	s1,24(sp)
    80003ebe:	e84a                	sd	s2,16(sp)
    80003ec0:	e44e                	sd	s3,8(sp)
    80003ec2:	e052                	sd	s4,0(sp)
    80003ec4:	1800                	addi	s0,sp,48
    80003ec6:	89aa                	mv	s3,a0
    80003ec8:	8a2e                	mv	s4,a1
  initlock(&log[dev].lock, "log");
    80003eca:	0a800713          	li	a4,168
    80003ece:	02e504b3          	mul	s1,a0,a4
    80003ed2:	0001e917          	auipc	s2,0x1e
    80003ed6:	8c690913          	addi	s2,s2,-1850 # 80021798 <log>
    80003eda:	9926                	add	s2,s2,s1
    80003edc:	00003597          	auipc	a1,0x3
    80003ee0:	72c58593          	addi	a1,a1,1836 # 80007608 <userret+0x578>
    80003ee4:	854a                	mv	a0,s2
    80003ee6:	ffffd097          	auipc	ra,0xffffd
    80003eea:	b0c080e7          	jalr	-1268(ra) # 800009f2 <initlock>
  log[dev].start = sb->logstart;
    80003eee:	014a2583          	lw	a1,20(s4)
    80003ef2:	00b92c23          	sw	a1,24(s2)
  log[dev].size = sb->nlog;
    80003ef6:	010a2783          	lw	a5,16(s4)
    80003efa:	00f92e23          	sw	a5,28(s2)
  log[dev].dev = dev;
    80003efe:	03392423          	sw	s3,40(s2)
  struct buf *buf = bread(dev, log[dev].start);
    80003f02:	854e                	mv	a0,s3
    80003f04:	fffff097          	auipc	ra,0xfffff
    80003f08:	d80080e7          	jalr	-640(ra) # 80002c84 <bread>
  log[dev].lh.n = lh->n;
    80003f0c:	513c                	lw	a5,96(a0)
    80003f0e:	02f92623          	sw	a5,44(s2)
  for (i = 0; i < log[dev].lh.n; i++) {
    80003f12:	02f05663          	blez	a5,80003f3e <initlog+0x88>
    80003f16:	06450693          	addi	a3,a0,100
    80003f1a:	0001e717          	auipc	a4,0x1e
    80003f1e:	8ae70713          	addi	a4,a4,-1874 # 800217c8 <log+0x30>
    80003f22:	9726                	add	a4,a4,s1
    80003f24:	37fd                	addiw	a5,a5,-1
    80003f26:	1782                	slli	a5,a5,0x20
    80003f28:	9381                	srli	a5,a5,0x20
    80003f2a:	078a                	slli	a5,a5,0x2
    80003f2c:	06850613          	addi	a2,a0,104
    80003f30:	97b2                	add	a5,a5,a2
    log[dev].lh.block[i] = lh->block[i];
    80003f32:	4290                	lw	a2,0(a3)
    80003f34:	c310                	sw	a2,0(a4)
  for (i = 0; i < log[dev].lh.n; i++) {
    80003f36:	0691                	addi	a3,a3,4
    80003f38:	0711                	addi	a4,a4,4
    80003f3a:	fef69ce3          	bne	a3,a5,80003f32 <initlog+0x7c>
  brelse(buf);
    80003f3e:	fffff097          	auipc	ra,0xfffff
    80003f42:	e8c080e7          	jalr	-372(ra) # 80002dca <brelse>
  install_trans(dev); // if committed, copy from log to disk
    80003f46:	854e                	mv	a0,s3
    80003f48:	00000097          	auipc	ra,0x0
    80003f4c:	ea2080e7          	jalr	-350(ra) # 80003dea <install_trans>
  log[dev].lh.n = 0;
    80003f50:	0a800793          	li	a5,168
    80003f54:	02f98733          	mul	a4,s3,a5
    80003f58:	0001e797          	auipc	a5,0x1e
    80003f5c:	84078793          	addi	a5,a5,-1984 # 80021798 <log>
    80003f60:	97ba                	add	a5,a5,a4
    80003f62:	0207a623          	sw	zero,44(a5)
  write_head(dev); // clear the log
    80003f66:	854e                	mv	a0,s3
    80003f68:	00000097          	auipc	ra,0x0
    80003f6c:	d38080e7          	jalr	-712(ra) # 80003ca0 <write_head>
}
    80003f70:	70a2                	ld	ra,40(sp)
    80003f72:	7402                	ld	s0,32(sp)
    80003f74:	64e2                	ld	s1,24(sp)
    80003f76:	6942                	ld	s2,16(sp)
    80003f78:	69a2                	ld	s3,8(sp)
    80003f7a:	6a02                	ld	s4,0(sp)
    80003f7c:	6145                	addi	sp,sp,48
    80003f7e:	8082                	ret

0000000080003f80 <begin_op>:
{
    80003f80:	7139                	addi	sp,sp,-64
    80003f82:	fc06                	sd	ra,56(sp)
    80003f84:	f822                	sd	s0,48(sp)
    80003f86:	f426                	sd	s1,40(sp)
    80003f88:	f04a                	sd	s2,32(sp)
    80003f8a:	ec4e                	sd	s3,24(sp)
    80003f8c:	e852                	sd	s4,16(sp)
    80003f8e:	e456                	sd	s5,8(sp)
    80003f90:	0080                	addi	s0,sp,64
    80003f92:	8aaa                	mv	s5,a0
  acquire(&log[dev].lock);
    80003f94:	0a800913          	li	s2,168
    80003f98:	032507b3          	mul	a5,a0,s2
    80003f9c:	0001d917          	auipc	s2,0x1d
    80003fa0:	7fc90913          	addi	s2,s2,2044 # 80021798 <log>
    80003fa4:	993e                	add	s2,s2,a5
    80003fa6:	854a                	mv	a0,s2
    80003fa8:	ffffd097          	auipc	ra,0xffffd
    80003fac:	b58080e7          	jalr	-1192(ra) # 80000b00 <acquire>
    if(log[dev].committing){
    80003fb0:	0001d997          	auipc	s3,0x1d
    80003fb4:	7e898993          	addi	s3,s3,2024 # 80021798 <log>
    80003fb8:	84ca                	mv	s1,s2
    } else if(log[dev].lh.n + (log[dev].outstanding+1)*MAXOPBLOCKS > LOGSIZE){
    80003fba:	4a79                	li	s4,30
    80003fbc:	a039                	j	80003fca <begin_op+0x4a>
      sleep(&log, &log[dev].lock);
    80003fbe:	85ca                	mv	a1,s2
    80003fc0:	854e                	mv	a0,s3
    80003fc2:	ffffe097          	auipc	ra,0xffffe
    80003fc6:	0ea080e7          	jalr	234(ra) # 800020ac <sleep>
    if(log[dev].committing){
    80003fca:	50dc                	lw	a5,36(s1)
    80003fcc:	fbed                	bnez	a5,80003fbe <begin_op+0x3e>
    } else if(log[dev].lh.n + (log[dev].outstanding+1)*MAXOPBLOCKS > LOGSIZE){
    80003fce:	509c                	lw	a5,32(s1)
    80003fd0:	0017871b          	addiw	a4,a5,1
    80003fd4:	0007069b          	sext.w	a3,a4
    80003fd8:	0027179b          	slliw	a5,a4,0x2
    80003fdc:	9fb9                	addw	a5,a5,a4
    80003fde:	0017979b          	slliw	a5,a5,0x1
    80003fe2:	54d8                	lw	a4,44(s1)
    80003fe4:	9fb9                	addw	a5,a5,a4
    80003fe6:	00fa5963          	ble	a5,s4,80003ff8 <begin_op+0x78>
      sleep(&log, &log[dev].lock);
    80003fea:	85ca                	mv	a1,s2
    80003fec:	854e                	mv	a0,s3
    80003fee:	ffffe097          	auipc	ra,0xffffe
    80003ff2:	0be080e7          	jalr	190(ra) # 800020ac <sleep>
    80003ff6:	bfd1                	j	80003fca <begin_op+0x4a>
      log[dev].outstanding += 1;
    80003ff8:	0a800793          	li	a5,168
    80003ffc:	02fa8ab3          	mul	s5,s5,a5
    80004000:	0001d797          	auipc	a5,0x1d
    80004004:	79878793          	addi	a5,a5,1944 # 80021798 <log>
    80004008:	9abe                	add	s5,s5,a5
    8000400a:	02daa023          	sw	a3,32(s5)
      release(&log[dev].lock);
    8000400e:	854a                	mv	a0,s2
    80004010:	ffffd097          	auipc	ra,0xffffd
    80004014:	b58080e7          	jalr	-1192(ra) # 80000b68 <release>
}
    80004018:	70e2                	ld	ra,56(sp)
    8000401a:	7442                	ld	s0,48(sp)
    8000401c:	74a2                	ld	s1,40(sp)
    8000401e:	7902                	ld	s2,32(sp)
    80004020:	69e2                	ld	s3,24(sp)
    80004022:	6a42                	ld	s4,16(sp)
    80004024:	6aa2                	ld	s5,8(sp)
    80004026:	6121                	addi	sp,sp,64
    80004028:	8082                	ret

000000008000402a <end_op>:
{
    8000402a:	7179                	addi	sp,sp,-48
    8000402c:	f406                	sd	ra,40(sp)
    8000402e:	f022                	sd	s0,32(sp)
    80004030:	ec26                	sd	s1,24(sp)
    80004032:	e84a                	sd	s2,16(sp)
    80004034:	e44e                	sd	s3,8(sp)
    80004036:	1800                	addi	s0,sp,48
    80004038:	892a                	mv	s2,a0
  acquire(&log[dev].lock);
    8000403a:	0a800493          	li	s1,168
    8000403e:	029507b3          	mul	a5,a0,s1
    80004042:	0001d497          	auipc	s1,0x1d
    80004046:	75648493          	addi	s1,s1,1878 # 80021798 <log>
    8000404a:	94be                	add	s1,s1,a5
    8000404c:	8526                	mv	a0,s1
    8000404e:	ffffd097          	auipc	ra,0xffffd
    80004052:	ab2080e7          	jalr	-1358(ra) # 80000b00 <acquire>
  log[dev].outstanding -= 1;
    80004056:	509c                	lw	a5,32(s1)
    80004058:	37fd                	addiw	a5,a5,-1
    8000405a:	0007871b          	sext.w	a4,a5
    8000405e:	d09c                	sw	a5,32(s1)
  if(log[dev].committing)
    80004060:	50dc                	lw	a5,36(s1)
    80004062:	e3ad                	bnez	a5,800040c4 <end_op+0x9a>
  if(log[dev].outstanding == 0){
    80004064:	eb25                	bnez	a4,800040d4 <end_op+0xaa>
    log[dev].committing = 1;
    80004066:	0a800993          	li	s3,168
    8000406a:	033907b3          	mul	a5,s2,s3
    8000406e:	0001d997          	auipc	s3,0x1d
    80004072:	72a98993          	addi	s3,s3,1834 # 80021798 <log>
    80004076:	99be                	add	s3,s3,a5
    80004078:	4785                	li	a5,1
    8000407a:	02f9a223          	sw	a5,36(s3)
  release(&log[dev].lock);
    8000407e:	8526                	mv	a0,s1
    80004080:	ffffd097          	auipc	ra,0xffffd
    80004084:	ae8080e7          	jalr	-1304(ra) # 80000b68 <release>

static void
commit(int dev)
{
  if (log[dev].lh.n > 0) {
    80004088:	02c9a783          	lw	a5,44(s3)
    8000408c:	06f04863          	bgtz	a5,800040fc <end_op+0xd2>
    acquire(&log[dev].lock);
    80004090:	8526                	mv	a0,s1
    80004092:	ffffd097          	auipc	ra,0xffffd
    80004096:	a6e080e7          	jalr	-1426(ra) # 80000b00 <acquire>
    log[dev].committing = 0;
    8000409a:	0001d517          	auipc	a0,0x1d
    8000409e:	6fe50513          	addi	a0,a0,1790 # 80021798 <log>
    800040a2:	0a800793          	li	a5,168
    800040a6:	02f90933          	mul	s2,s2,a5
    800040aa:	992a                	add	s2,s2,a0
    800040ac:	02092223          	sw	zero,36(s2)
    wakeup(&log);
    800040b0:	ffffe097          	auipc	ra,0xffffe
    800040b4:	148080e7          	jalr	328(ra) # 800021f8 <wakeup>
    release(&log[dev].lock);
    800040b8:	8526                	mv	a0,s1
    800040ba:	ffffd097          	auipc	ra,0xffffd
    800040be:	aae080e7          	jalr	-1362(ra) # 80000b68 <release>
}
    800040c2:	a035                	j	800040ee <end_op+0xc4>
    panic("log[dev].committing");
    800040c4:	00003517          	auipc	a0,0x3
    800040c8:	54c50513          	addi	a0,a0,1356 # 80007610 <userret+0x580>
    800040cc:	ffffc097          	auipc	ra,0xffffc
    800040d0:	4b2080e7          	jalr	1202(ra) # 8000057e <panic>
    wakeup(&log);
    800040d4:	0001d517          	auipc	a0,0x1d
    800040d8:	6c450513          	addi	a0,a0,1732 # 80021798 <log>
    800040dc:	ffffe097          	auipc	ra,0xffffe
    800040e0:	11c080e7          	jalr	284(ra) # 800021f8 <wakeup>
  release(&log[dev].lock);
    800040e4:	8526                	mv	a0,s1
    800040e6:	ffffd097          	auipc	ra,0xffffd
    800040ea:	a82080e7          	jalr	-1406(ra) # 80000b68 <release>
}
    800040ee:	70a2                	ld	ra,40(sp)
    800040f0:	7402                	ld	s0,32(sp)
    800040f2:	64e2                	ld	s1,24(sp)
    800040f4:	6942                	ld	s2,16(sp)
    800040f6:	69a2                	ld	s3,8(sp)
    800040f8:	6145                	addi	sp,sp,48
    800040fa:	8082                	ret
    write_log(dev);     // Write modified blocks from cache to log
    800040fc:	854a                	mv	a0,s2
    800040fe:	00000097          	auipc	ra,0x0
    80004102:	c2c080e7          	jalr	-980(ra) # 80003d2a <write_log>
    write_head(dev);    // Write header to disk -- the real commit
    80004106:	854a                	mv	a0,s2
    80004108:	00000097          	auipc	ra,0x0
    8000410c:	b98080e7          	jalr	-1128(ra) # 80003ca0 <write_head>
    install_trans(dev); // Now install writes to home locations
    80004110:	854a                	mv	a0,s2
    80004112:	00000097          	auipc	ra,0x0
    80004116:	cd8080e7          	jalr	-808(ra) # 80003dea <install_trans>
    log[dev].lh.n = 0;
    8000411a:	0a800793          	li	a5,168
    8000411e:	02f90733          	mul	a4,s2,a5
    80004122:	0001d797          	auipc	a5,0x1d
    80004126:	67678793          	addi	a5,a5,1654 # 80021798 <log>
    8000412a:	97ba                	add	a5,a5,a4
    8000412c:	0207a623          	sw	zero,44(a5)
    write_head(dev);    // Erase the transaction from the log
    80004130:	854a                	mv	a0,s2
    80004132:	00000097          	auipc	ra,0x0
    80004136:	b6e080e7          	jalr	-1170(ra) # 80003ca0 <write_head>
    8000413a:	bf99                	j	80004090 <end_op+0x66>

000000008000413c <log_write>:
//   modify bp->data[]
//   log_write(bp)
//   brelse(bp)
void
log_write(struct buf *b)
{
    8000413c:	7179                	addi	sp,sp,-48
    8000413e:	f406                	sd	ra,40(sp)
    80004140:	f022                	sd	s0,32(sp)
    80004142:	ec26                	sd	s1,24(sp)
    80004144:	e84a                	sd	s2,16(sp)
    80004146:	e44e                	sd	s3,8(sp)
    80004148:	e052                	sd	s4,0(sp)
    8000414a:	1800                	addi	s0,sp,48
  int i;

  int dev = b->dev;
    8000414c:	00852903          	lw	s2,8(a0)
  if (log[dev].lh.n >= LOGSIZE || log[dev].lh.n >= log[dev].size - 1)
    80004150:	0a800793          	li	a5,168
    80004154:	02f90733          	mul	a4,s2,a5
    80004158:	0001d797          	auipc	a5,0x1d
    8000415c:	64078793          	addi	a5,a5,1600 # 80021798 <log>
    80004160:	97ba                	add	a5,a5,a4
    80004162:	57d4                	lw	a3,44(a5)
    80004164:	47f5                	li	a5,29
    80004166:	0ad7c763          	blt	a5,a3,80004214 <log_write+0xd8>
    8000416a:	8a2a                	mv	s4,a0
    8000416c:	0001d797          	auipc	a5,0x1d
    80004170:	62c78793          	addi	a5,a5,1580 # 80021798 <log>
    80004174:	97ba                	add	a5,a5,a4
    80004176:	4fdc                	lw	a5,28(a5)
    80004178:	37fd                	addiw	a5,a5,-1
    8000417a:	08f6dd63          	ble	a5,a3,80004214 <log_write+0xd8>
    panic("too big a transaction");
  if (log[dev].outstanding < 1)
    8000417e:	0a800793          	li	a5,168
    80004182:	02f90733          	mul	a4,s2,a5
    80004186:	0001d797          	auipc	a5,0x1d
    8000418a:	61278793          	addi	a5,a5,1554 # 80021798 <log>
    8000418e:	97ba                	add	a5,a5,a4
    80004190:	539c                	lw	a5,32(a5)
    80004192:	08f05963          	blez	a5,80004224 <log_write+0xe8>
    panic("log_write outside of trans");

  acquire(&log[dev].lock);
    80004196:	0a800793          	li	a5,168
    8000419a:	02f904b3          	mul	s1,s2,a5
    8000419e:	0001d997          	auipc	s3,0x1d
    800041a2:	5fa98993          	addi	s3,s3,1530 # 80021798 <log>
    800041a6:	99a6                	add	s3,s3,s1
    800041a8:	854e                	mv	a0,s3
    800041aa:	ffffd097          	auipc	ra,0xffffd
    800041ae:	956080e7          	jalr	-1706(ra) # 80000b00 <acquire>
  for (i = 0; i < log[dev].lh.n; i++) {
    800041b2:	02c9a603          	lw	a2,44(s3)
    800041b6:	0cc05263          	blez	a2,8000427a <log_write+0x13e>
    if (log[dev].lh.block[i] == b->blockno)   // log absorbtion
    800041ba:	00ca2583          	lw	a1,12(s4)
    800041be:	0309a783          	lw	a5,48(s3)
    800041c2:	0cb78a63          	beq	a5,a1,80004296 <log_write+0x15a>
    800041c6:	0001d797          	auipc	a5,0x1d
    800041ca:	60678793          	addi	a5,a5,1542 # 800217cc <log+0x34>
    800041ce:	97a6                	add	a5,a5,s1
  for (i = 0; i < log[dev].lh.n; i++) {
    800041d0:	4701                	li	a4,0
    800041d2:	2705                	addiw	a4,a4,1
    800041d4:	06c70063          	beq	a4,a2,80004234 <log_write+0xf8>
    if (log[dev].lh.block[i] == b->blockno)   // log absorbtion
    800041d8:	4394                	lw	a3,0(a5)
    800041da:	0791                	addi	a5,a5,4
    800041dc:	feb69be3          	bne	a3,a1,800041d2 <log_write+0x96>
      break;
  }
  log[dev].lh.block[i] = b->blockno;
    800041e0:	02a00793          	li	a5,42
    800041e4:	02f907b3          	mul	a5,s2,a5
    800041e8:	97ba                	add	a5,a5,a4
    800041ea:	07a1                	addi	a5,a5,8
    800041ec:	078a                	slli	a5,a5,0x2
    800041ee:	0001d717          	auipc	a4,0x1d
    800041f2:	5aa70713          	addi	a4,a4,1450 # 80021798 <log>
    800041f6:	97ba                	add	a5,a5,a4
    800041f8:	cb8c                	sw	a1,16(a5)
  if (i == log[dev].lh.n) {  // Add new block to log?
    bpin(b);
    log[dev].lh.n++;
  }
  release(&log[dev].lock);
    800041fa:	854e                	mv	a0,s3
    800041fc:	ffffd097          	auipc	ra,0xffffd
    80004200:	96c080e7          	jalr	-1684(ra) # 80000b68 <release>
}
    80004204:	70a2                	ld	ra,40(sp)
    80004206:	7402                	ld	s0,32(sp)
    80004208:	64e2                	ld	s1,24(sp)
    8000420a:	6942                	ld	s2,16(sp)
    8000420c:	69a2                	ld	s3,8(sp)
    8000420e:	6a02                	ld	s4,0(sp)
    80004210:	6145                	addi	sp,sp,48
    80004212:	8082                	ret
    panic("too big a transaction");
    80004214:	00003517          	auipc	a0,0x3
    80004218:	41450513          	addi	a0,a0,1044 # 80007628 <userret+0x598>
    8000421c:	ffffc097          	auipc	ra,0xffffc
    80004220:	362080e7          	jalr	866(ra) # 8000057e <panic>
    panic("log_write outside of trans");
    80004224:	00003517          	auipc	a0,0x3
    80004228:	41c50513          	addi	a0,a0,1052 # 80007640 <userret+0x5b0>
    8000422c:	ffffc097          	auipc	ra,0xffffc
    80004230:	352080e7          	jalr	850(ra) # 8000057e <panic>
  log[dev].lh.block[i] = b->blockno;
    80004234:	02a00793          	li	a5,42
    80004238:	02f907b3          	mul	a5,s2,a5
    8000423c:	97b2                	add	a5,a5,a2
    8000423e:	07a1                	addi	a5,a5,8
    80004240:	078a                	slli	a5,a5,0x2
    80004242:	0001d717          	auipc	a4,0x1d
    80004246:	55670713          	addi	a4,a4,1366 # 80021798 <log>
    8000424a:	97ba                	add	a5,a5,a4
    8000424c:	00ca2703          	lw	a4,12(s4)
    80004250:	cb98                	sw	a4,16(a5)
    bpin(b);
    80004252:	8552                	mv	a0,s4
    80004254:	fffff097          	auipc	ra,0xfffff
    80004258:	c14080e7          	jalr	-1004(ra) # 80002e68 <bpin>
    log[dev].lh.n++;
    8000425c:	0a800793          	li	a5,168
    80004260:	02f907b3          	mul	a5,s2,a5
    80004264:	0001d917          	auipc	s2,0x1d
    80004268:	53490913          	addi	s2,s2,1332 # 80021798 <log>
    8000426c:	993e                	add	s2,s2,a5
    8000426e:	02c92783          	lw	a5,44(s2)
    80004272:	2785                	addiw	a5,a5,1
    80004274:	02f92623          	sw	a5,44(s2)
    80004278:	b749                	j	800041fa <log_write+0xbe>
  log[dev].lh.block[i] = b->blockno;
    8000427a:	0a800793          	li	a5,168
    8000427e:	02f90733          	mul	a4,s2,a5
    80004282:	0001d797          	auipc	a5,0x1d
    80004286:	51678793          	addi	a5,a5,1302 # 80021798 <log>
    8000428a:	97ba                	add	a5,a5,a4
    8000428c:	00ca2703          	lw	a4,12(s4)
    80004290:	db98                	sw	a4,48(a5)
  if (i == log[dev].lh.n) {  // Add new block to log?
    80004292:	f625                	bnez	a2,800041fa <log_write+0xbe>
    80004294:	bf7d                	j	80004252 <log_write+0x116>
  for (i = 0; i < log[dev].lh.n; i++) {
    80004296:	4701                	li	a4,0
    80004298:	b7a1                	j	800041e0 <log_write+0xa4>

000000008000429a <crash_op>:

// crash before commit or after commit
void
crash_op(int dev, int docommit)
{
    8000429a:	7179                	addi	sp,sp,-48
    8000429c:	f406                	sd	ra,40(sp)
    8000429e:	f022                	sd	s0,32(sp)
    800042a0:	ec26                	sd	s1,24(sp)
    800042a2:	e84a                	sd	s2,16(sp)
    800042a4:	e44e                	sd	s3,8(sp)
    800042a6:	1800                	addi	s0,sp,48
    800042a8:	84aa                	mv	s1,a0
    800042aa:	89ae                	mv	s3,a1
  int do_commit = 0;
    
  acquire(&log[dev].lock);
    800042ac:	0a800913          	li	s2,168
    800042b0:	032507b3          	mul	a5,a0,s2
    800042b4:	0001d917          	auipc	s2,0x1d
    800042b8:	4e490913          	addi	s2,s2,1252 # 80021798 <log>
    800042bc:	993e                	add	s2,s2,a5
    800042be:	854a                	mv	a0,s2
    800042c0:	ffffd097          	auipc	ra,0xffffd
    800042c4:	840080e7          	jalr	-1984(ra) # 80000b00 <acquire>

  if (dev < 0 || dev >= NDISK)
    800042c8:	0004871b          	sext.w	a4,s1
    800042cc:	4785                	li	a5,1
    800042ce:	0ae7e063          	bltu	a5,a4,8000436e <crash_op+0xd4>
    panic("end_op: invalid disk");
  if(log[dev].outstanding == 0)
    800042d2:	0a800793          	li	a5,168
    800042d6:	02f48733          	mul	a4,s1,a5
    800042da:	0001d797          	auipc	a5,0x1d
    800042de:	4be78793          	addi	a5,a5,1214 # 80021798 <log>
    800042e2:	97ba                	add	a5,a5,a4
    800042e4:	539c                	lw	a5,32(a5)
    800042e6:	cfc1                	beqz	a5,8000437e <crash_op+0xe4>
    panic("end_op: already closed");
  log[dev].outstanding -= 1;
    800042e8:	37fd                	addiw	a5,a5,-1
    800042ea:	0007861b          	sext.w	a2,a5
    800042ee:	0a800713          	li	a4,168
    800042f2:	02e486b3          	mul	a3,s1,a4
    800042f6:	0001d717          	auipc	a4,0x1d
    800042fa:	4a270713          	addi	a4,a4,1186 # 80021798 <log>
    800042fe:	9736                	add	a4,a4,a3
    80004300:	d31c                	sw	a5,32(a4)
  if(log[dev].committing)
    80004302:	535c                	lw	a5,36(a4)
    80004304:	e7c9                	bnez	a5,8000438e <crash_op+0xf4>
    panic("log[dev].committing");
  if(log[dev].outstanding == 0){
    80004306:	ee41                	bnez	a2,8000439e <crash_op+0x104>
    do_commit = 1;
    log[dev].committing = 1;
    80004308:	0a800793          	li	a5,168
    8000430c:	02f48733          	mul	a4,s1,a5
    80004310:	0001d797          	auipc	a5,0x1d
    80004314:	48878793          	addi	a5,a5,1160 # 80021798 <log>
    80004318:	97ba                	add	a5,a5,a4
    8000431a:	4705                	li	a4,1
    8000431c:	d3d8                	sw	a4,36(a5)
  }
  
  release(&log[dev].lock);
    8000431e:	854a                	mv	a0,s2
    80004320:	ffffd097          	auipc	ra,0xffffd
    80004324:	848080e7          	jalr	-1976(ra) # 80000b68 <release>

  if(docommit & do_commit){
    80004328:	0019f993          	andi	s3,s3,1
    8000432c:	06098e63          	beqz	s3,800043a8 <crash_op+0x10e>
    printf("crash_op: commit\n");
    80004330:	00003517          	auipc	a0,0x3
    80004334:	36050513          	addi	a0,a0,864 # 80007690 <userret+0x600>
    80004338:	ffffc097          	auipc	ra,0xffffc
    8000433c:	290080e7          	jalr	656(ra) # 800005c8 <printf>
    // call commit w/o holding locks, since not allowed
    // to sleep with locks.

    if (log[dev].lh.n > 0) {
    80004340:	0a800793          	li	a5,168
    80004344:	02f48733          	mul	a4,s1,a5
    80004348:	0001d797          	auipc	a5,0x1d
    8000434c:	45078793          	addi	a5,a5,1104 # 80021798 <log>
    80004350:	97ba                	add	a5,a5,a4
    80004352:	57dc                	lw	a5,44(a5)
    80004354:	04f05a63          	blez	a5,800043a8 <crash_op+0x10e>
      write_log(dev);     // Write modified blocks from cache to log
    80004358:	8526                	mv	a0,s1
    8000435a:	00000097          	auipc	ra,0x0
    8000435e:	9d0080e7          	jalr	-1584(ra) # 80003d2a <write_log>
      write_head(dev);    // Write header to disk -- the real commit
    80004362:	8526                	mv	a0,s1
    80004364:	00000097          	auipc	ra,0x0
    80004368:	93c080e7          	jalr	-1732(ra) # 80003ca0 <write_head>
    8000436c:	a835                	j	800043a8 <crash_op+0x10e>
    panic("end_op: invalid disk");
    8000436e:	00003517          	auipc	a0,0x3
    80004372:	2f250513          	addi	a0,a0,754 # 80007660 <userret+0x5d0>
    80004376:	ffffc097          	auipc	ra,0xffffc
    8000437a:	208080e7          	jalr	520(ra) # 8000057e <panic>
    panic("end_op: already closed");
    8000437e:	00003517          	auipc	a0,0x3
    80004382:	2fa50513          	addi	a0,a0,762 # 80007678 <userret+0x5e8>
    80004386:	ffffc097          	auipc	ra,0xffffc
    8000438a:	1f8080e7          	jalr	504(ra) # 8000057e <panic>
    panic("log[dev].committing");
    8000438e:	00003517          	auipc	a0,0x3
    80004392:	28250513          	addi	a0,a0,642 # 80007610 <userret+0x580>
    80004396:	ffffc097          	auipc	ra,0xffffc
    8000439a:	1e8080e7          	jalr	488(ra) # 8000057e <panic>
  release(&log[dev].lock);
    8000439e:	854a                	mv	a0,s2
    800043a0:	ffffc097          	auipc	ra,0xffffc
    800043a4:	7c8080e7          	jalr	1992(ra) # 80000b68 <release>
    }
  }
  panic("crashed file system; please restart xv6 and run crashtest\n");
    800043a8:	00003517          	auipc	a0,0x3
    800043ac:	30050513          	addi	a0,a0,768 # 800076a8 <userret+0x618>
    800043b0:	ffffc097          	auipc	ra,0xffffc
    800043b4:	1ce080e7          	jalr	462(ra) # 8000057e <panic>

00000000800043b8 <initsleeplock>:
#include "proc.h"
#include "sleeplock.h"

void
initsleeplock(struct sleeplock *lk, char *name)
{
    800043b8:	1101                	addi	sp,sp,-32
    800043ba:	ec06                	sd	ra,24(sp)
    800043bc:	e822                	sd	s0,16(sp)
    800043be:	e426                	sd	s1,8(sp)
    800043c0:	e04a                	sd	s2,0(sp)
    800043c2:	1000                	addi	s0,sp,32
    800043c4:	84aa                	mv	s1,a0
    800043c6:	892e                	mv	s2,a1
  initlock(&lk->lk, "sleep lock");
    800043c8:	00003597          	auipc	a1,0x3
    800043cc:	32058593          	addi	a1,a1,800 # 800076e8 <userret+0x658>
    800043d0:	0521                	addi	a0,a0,8
    800043d2:	ffffc097          	auipc	ra,0xffffc
    800043d6:	620080e7          	jalr	1568(ra) # 800009f2 <initlock>
  lk->name = name;
    800043da:	0324b023          	sd	s2,32(s1)
  lk->locked = 0;
    800043de:	0004a023          	sw	zero,0(s1)
  lk->pid = 0;
    800043e2:	0204a423          	sw	zero,40(s1)
}
    800043e6:	60e2                	ld	ra,24(sp)
    800043e8:	6442                	ld	s0,16(sp)
    800043ea:	64a2                	ld	s1,8(sp)
    800043ec:	6902                	ld	s2,0(sp)
    800043ee:	6105                	addi	sp,sp,32
    800043f0:	8082                	ret

00000000800043f2 <acquiresleep>:

void
acquiresleep(struct sleeplock *lk)
{
    800043f2:	1101                	addi	sp,sp,-32
    800043f4:	ec06                	sd	ra,24(sp)
    800043f6:	e822                	sd	s0,16(sp)
    800043f8:	e426                	sd	s1,8(sp)
    800043fa:	e04a                	sd	s2,0(sp)
    800043fc:	1000                	addi	s0,sp,32
    800043fe:	84aa                	mv	s1,a0
  acquire(&lk->lk);
    80004400:	00850913          	addi	s2,a0,8
    80004404:	854a                	mv	a0,s2
    80004406:	ffffc097          	auipc	ra,0xffffc
    8000440a:	6fa080e7          	jalr	1786(ra) # 80000b00 <acquire>
  while (lk->locked) {
    8000440e:	409c                	lw	a5,0(s1)
    80004410:	cb89                	beqz	a5,80004422 <acquiresleep+0x30>
    sleep(lk, &lk->lk);
    80004412:	85ca                	mv	a1,s2
    80004414:	8526                	mv	a0,s1
    80004416:	ffffe097          	auipc	ra,0xffffe
    8000441a:	c96080e7          	jalr	-874(ra) # 800020ac <sleep>
  while (lk->locked) {
    8000441e:	409c                	lw	a5,0(s1)
    80004420:	fbed                	bnez	a5,80004412 <acquiresleep+0x20>
  }
  lk->locked = 1;
    80004422:	4785                	li	a5,1
    80004424:	c09c                	sw	a5,0(s1)
  lk->pid = myproc()->pid;
    80004426:	ffffd097          	auipc	ra,0xffffd
    8000442a:	478080e7          	jalr	1144(ra) # 8000189e <myproc>
    8000442e:	595c                	lw	a5,52(a0)
    80004430:	d49c                	sw	a5,40(s1)
  release(&lk->lk);
    80004432:	854a                	mv	a0,s2
    80004434:	ffffc097          	auipc	ra,0xffffc
    80004438:	734080e7          	jalr	1844(ra) # 80000b68 <release>
}
    8000443c:	60e2                	ld	ra,24(sp)
    8000443e:	6442                	ld	s0,16(sp)
    80004440:	64a2                	ld	s1,8(sp)
    80004442:	6902                	ld	s2,0(sp)
    80004444:	6105                	addi	sp,sp,32
    80004446:	8082                	ret

0000000080004448 <releasesleep>:

void
releasesleep(struct sleeplock *lk)
{
    80004448:	1101                	addi	sp,sp,-32
    8000444a:	ec06                	sd	ra,24(sp)
    8000444c:	e822                	sd	s0,16(sp)
    8000444e:	e426                	sd	s1,8(sp)
    80004450:	e04a                	sd	s2,0(sp)
    80004452:	1000                	addi	s0,sp,32
    80004454:	84aa                	mv	s1,a0
  acquire(&lk->lk);
    80004456:	00850913          	addi	s2,a0,8
    8000445a:	854a                	mv	a0,s2
    8000445c:	ffffc097          	auipc	ra,0xffffc
    80004460:	6a4080e7          	jalr	1700(ra) # 80000b00 <acquire>
  lk->locked = 0;
    80004464:	0004a023          	sw	zero,0(s1)
  lk->pid = 0;
    80004468:	0204a423          	sw	zero,40(s1)
  wakeup(lk);
    8000446c:	8526                	mv	a0,s1
    8000446e:	ffffe097          	auipc	ra,0xffffe
    80004472:	d8a080e7          	jalr	-630(ra) # 800021f8 <wakeup>
  release(&lk->lk);
    80004476:	854a                	mv	a0,s2
    80004478:	ffffc097          	auipc	ra,0xffffc
    8000447c:	6f0080e7          	jalr	1776(ra) # 80000b68 <release>
}
    80004480:	60e2                	ld	ra,24(sp)
    80004482:	6442                	ld	s0,16(sp)
    80004484:	64a2                	ld	s1,8(sp)
    80004486:	6902                	ld	s2,0(sp)
    80004488:	6105                	addi	sp,sp,32
    8000448a:	8082                	ret

000000008000448c <holdingsleep>:

int
holdingsleep(struct sleeplock *lk)
{
    8000448c:	7179                	addi	sp,sp,-48
    8000448e:	f406                	sd	ra,40(sp)
    80004490:	f022                	sd	s0,32(sp)
    80004492:	ec26                	sd	s1,24(sp)
    80004494:	e84a                	sd	s2,16(sp)
    80004496:	e44e                	sd	s3,8(sp)
    80004498:	1800                	addi	s0,sp,48
    8000449a:	84aa                	mv	s1,a0
  int r;
  
  acquire(&lk->lk);
    8000449c:	00850913          	addi	s2,a0,8
    800044a0:	854a                	mv	a0,s2
    800044a2:	ffffc097          	auipc	ra,0xffffc
    800044a6:	65e080e7          	jalr	1630(ra) # 80000b00 <acquire>
  r = lk->locked && (lk->pid == myproc()->pid);
    800044aa:	409c                	lw	a5,0(s1)
    800044ac:	ef99                	bnez	a5,800044ca <holdingsleep+0x3e>
    800044ae:	4481                	li	s1,0
  release(&lk->lk);
    800044b0:	854a                	mv	a0,s2
    800044b2:	ffffc097          	auipc	ra,0xffffc
    800044b6:	6b6080e7          	jalr	1718(ra) # 80000b68 <release>
  return r;
}
    800044ba:	8526                	mv	a0,s1
    800044bc:	70a2                	ld	ra,40(sp)
    800044be:	7402                	ld	s0,32(sp)
    800044c0:	64e2                	ld	s1,24(sp)
    800044c2:	6942                	ld	s2,16(sp)
    800044c4:	69a2                	ld	s3,8(sp)
    800044c6:	6145                	addi	sp,sp,48
    800044c8:	8082                	ret
  r = lk->locked && (lk->pid == myproc()->pid);
    800044ca:	0284a983          	lw	s3,40(s1)
    800044ce:	ffffd097          	auipc	ra,0xffffd
    800044d2:	3d0080e7          	jalr	976(ra) # 8000189e <myproc>
    800044d6:	5944                	lw	s1,52(a0)
    800044d8:	413484b3          	sub	s1,s1,s3
    800044dc:	0014b493          	seqz	s1,s1
    800044e0:	bfc1                	j	800044b0 <holdingsleep+0x24>

00000000800044e2 <fileinit>:
  struct file file[NFILE];
} ftable;

void
fileinit(void)
{
    800044e2:	1141                	addi	sp,sp,-16
    800044e4:	e406                	sd	ra,8(sp)
    800044e6:	e022                	sd	s0,0(sp)
    800044e8:	0800                	addi	s0,sp,16
  initlock(&ftable.lock, "ftable");
    800044ea:	00003597          	auipc	a1,0x3
    800044ee:	20e58593          	addi	a1,a1,526 # 800076f8 <userret+0x668>
    800044f2:	0001d517          	auipc	a0,0x1d
    800044f6:	49650513          	addi	a0,a0,1174 # 80021988 <ftable>
    800044fa:	ffffc097          	auipc	ra,0xffffc
    800044fe:	4f8080e7          	jalr	1272(ra) # 800009f2 <initlock>
}
    80004502:	60a2                	ld	ra,8(sp)
    80004504:	6402                	ld	s0,0(sp)
    80004506:	0141                	addi	sp,sp,16
    80004508:	8082                	ret

000000008000450a <filealloc>:

// Allocate a file structure.
struct file*
filealloc(void)
{
    8000450a:	1101                	addi	sp,sp,-32
    8000450c:	ec06                	sd	ra,24(sp)
    8000450e:	e822                	sd	s0,16(sp)
    80004510:	e426                	sd	s1,8(sp)
    80004512:	1000                	addi	s0,sp,32
  struct file *f;

  acquire(&ftable.lock);
    80004514:	0001d517          	auipc	a0,0x1d
    80004518:	47450513          	addi	a0,a0,1140 # 80021988 <ftable>
    8000451c:	ffffc097          	auipc	ra,0xffffc
    80004520:	5e4080e7          	jalr	1508(ra) # 80000b00 <acquire>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    if(f->ref == 0){
    80004524:	0001d797          	auipc	a5,0x1d
    80004528:	46478793          	addi	a5,a5,1124 # 80021988 <ftable>
    8000452c:	4fdc                	lw	a5,28(a5)
    8000452e:	cb8d                	beqz	a5,80004560 <filealloc+0x56>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    80004530:	0001d497          	auipc	s1,0x1d
    80004534:	49848493          	addi	s1,s1,1176 # 800219c8 <ftable+0x40>
    80004538:	0001e717          	auipc	a4,0x1e
    8000453c:	40870713          	addi	a4,a4,1032 # 80022940 <ftable+0xfb8>
    if(f->ref == 0){
    80004540:	40dc                	lw	a5,4(s1)
    80004542:	c39d                	beqz	a5,80004568 <filealloc+0x5e>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    80004544:	02848493          	addi	s1,s1,40
    80004548:	fee49ce3          	bne	s1,a4,80004540 <filealloc+0x36>
      f->ref = 1;
      release(&ftable.lock);
      return f;
    }
  }
  release(&ftable.lock);
    8000454c:	0001d517          	auipc	a0,0x1d
    80004550:	43c50513          	addi	a0,a0,1084 # 80021988 <ftable>
    80004554:	ffffc097          	auipc	ra,0xffffc
    80004558:	614080e7          	jalr	1556(ra) # 80000b68 <release>
  return 0;
    8000455c:	4481                	li	s1,0
    8000455e:	a839                	j	8000457c <filealloc+0x72>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    80004560:	0001d497          	auipc	s1,0x1d
    80004564:	44048493          	addi	s1,s1,1088 # 800219a0 <ftable+0x18>
      f->ref = 1;
    80004568:	4785                	li	a5,1
    8000456a:	c0dc                	sw	a5,4(s1)
      release(&ftable.lock);
    8000456c:	0001d517          	auipc	a0,0x1d
    80004570:	41c50513          	addi	a0,a0,1052 # 80021988 <ftable>
    80004574:	ffffc097          	auipc	ra,0xffffc
    80004578:	5f4080e7          	jalr	1524(ra) # 80000b68 <release>
}
    8000457c:	8526                	mv	a0,s1
    8000457e:	60e2                	ld	ra,24(sp)
    80004580:	6442                	ld	s0,16(sp)
    80004582:	64a2                	ld	s1,8(sp)
    80004584:	6105                	addi	sp,sp,32
    80004586:	8082                	ret

0000000080004588 <filedup>:

// Increment ref count for file f.
struct file*
filedup(struct file *f)
{
    80004588:	1101                	addi	sp,sp,-32
    8000458a:	ec06                	sd	ra,24(sp)
    8000458c:	e822                	sd	s0,16(sp)
    8000458e:	e426                	sd	s1,8(sp)
    80004590:	1000                	addi	s0,sp,32
    80004592:	84aa                	mv	s1,a0
  acquire(&ftable.lock);
    80004594:	0001d517          	auipc	a0,0x1d
    80004598:	3f450513          	addi	a0,a0,1012 # 80021988 <ftable>
    8000459c:	ffffc097          	auipc	ra,0xffffc
    800045a0:	564080e7          	jalr	1380(ra) # 80000b00 <acquire>
  if(f->ref < 1)
    800045a4:	40dc                	lw	a5,4(s1)
    800045a6:	02f05263          	blez	a5,800045ca <filedup+0x42>
    panic("filedup");
  f->ref++;
    800045aa:	2785                	addiw	a5,a5,1
    800045ac:	c0dc                	sw	a5,4(s1)
  release(&ftable.lock);
    800045ae:	0001d517          	auipc	a0,0x1d
    800045b2:	3da50513          	addi	a0,a0,986 # 80021988 <ftable>
    800045b6:	ffffc097          	auipc	ra,0xffffc
    800045ba:	5b2080e7          	jalr	1458(ra) # 80000b68 <release>
  return f;
}
    800045be:	8526                	mv	a0,s1
    800045c0:	60e2                	ld	ra,24(sp)
    800045c2:	6442                	ld	s0,16(sp)
    800045c4:	64a2                	ld	s1,8(sp)
    800045c6:	6105                	addi	sp,sp,32
    800045c8:	8082                	ret
    panic("filedup");
    800045ca:	00003517          	auipc	a0,0x3
    800045ce:	13650513          	addi	a0,a0,310 # 80007700 <userret+0x670>
    800045d2:	ffffc097          	auipc	ra,0xffffc
    800045d6:	fac080e7          	jalr	-84(ra) # 8000057e <panic>

00000000800045da <fileclose>:

// Close file f.  (Decrement ref count, close when reaches 0.)
void
fileclose(struct file *f)
{
    800045da:	7139                	addi	sp,sp,-64
    800045dc:	fc06                	sd	ra,56(sp)
    800045de:	f822                	sd	s0,48(sp)
    800045e0:	f426                	sd	s1,40(sp)
    800045e2:	f04a                	sd	s2,32(sp)
    800045e4:	ec4e                	sd	s3,24(sp)
    800045e6:	e852                	sd	s4,16(sp)
    800045e8:	e456                	sd	s5,8(sp)
    800045ea:	0080                	addi	s0,sp,64
    800045ec:	84aa                	mv	s1,a0
  struct file ff;

  acquire(&ftable.lock);
    800045ee:	0001d517          	auipc	a0,0x1d
    800045f2:	39a50513          	addi	a0,a0,922 # 80021988 <ftable>
    800045f6:	ffffc097          	auipc	ra,0xffffc
    800045fa:	50a080e7          	jalr	1290(ra) # 80000b00 <acquire>
  if(f->ref < 1)
    800045fe:	40dc                	lw	a5,4(s1)
    80004600:	06f05563          	blez	a5,8000466a <fileclose+0x90>
    panic("fileclose");
  if(--f->ref > 0){
    80004604:	37fd                	addiw	a5,a5,-1
    80004606:	0007871b          	sext.w	a4,a5
    8000460a:	c0dc                	sw	a5,4(s1)
    8000460c:	06e04763          	bgtz	a4,8000467a <fileclose+0xa0>
    release(&ftable.lock);
    return;
  }
  ff = *f;
    80004610:	0004a903          	lw	s2,0(s1)
    80004614:	0094ca83          	lbu	s5,9(s1)
    80004618:	0104ba03          	ld	s4,16(s1)
    8000461c:	0184b983          	ld	s3,24(s1)
  f->ref = 0;
    80004620:	0004a223          	sw	zero,4(s1)
  f->type = FD_NONE;
    80004624:	0004a023          	sw	zero,0(s1)
  release(&ftable.lock);
    80004628:	0001d517          	auipc	a0,0x1d
    8000462c:	36050513          	addi	a0,a0,864 # 80021988 <ftable>
    80004630:	ffffc097          	auipc	ra,0xffffc
    80004634:	538080e7          	jalr	1336(ra) # 80000b68 <release>

  if(ff.type == FD_PIPE){
    80004638:	4785                	li	a5,1
    8000463a:	06f90163          	beq	s2,a5,8000469c <fileclose+0xc2>
    pipeclose(ff.pipe, ff.writable);
  } else if(ff.type == FD_INODE || ff.type == FD_DEVICE){
    8000463e:	3979                	addiw	s2,s2,-2
    80004640:	4785                	li	a5,1
    80004642:	0527e463          	bltu	a5,s2,8000468a <fileclose+0xb0>
    begin_op(ff.ip->dev);
    80004646:	0009a503          	lw	a0,0(s3)
    8000464a:	00000097          	auipc	ra,0x0
    8000464e:	936080e7          	jalr	-1738(ra) # 80003f80 <begin_op>
    iput(ff.ip);
    80004652:	854e                	mv	a0,s3
    80004654:	fffff097          	auipc	ra,0xfffff
    80004658:	f8c080e7          	jalr	-116(ra) # 800035e0 <iput>
    end_op(ff.ip->dev);
    8000465c:	0009a503          	lw	a0,0(s3)
    80004660:	00000097          	auipc	ra,0x0
    80004664:	9ca080e7          	jalr	-1590(ra) # 8000402a <end_op>
    80004668:	a00d                	j	8000468a <fileclose+0xb0>
    panic("fileclose");
    8000466a:	00003517          	auipc	a0,0x3
    8000466e:	09e50513          	addi	a0,a0,158 # 80007708 <userret+0x678>
    80004672:	ffffc097          	auipc	ra,0xffffc
    80004676:	f0c080e7          	jalr	-244(ra) # 8000057e <panic>
    release(&ftable.lock);
    8000467a:	0001d517          	auipc	a0,0x1d
    8000467e:	30e50513          	addi	a0,a0,782 # 80021988 <ftable>
    80004682:	ffffc097          	auipc	ra,0xffffc
    80004686:	4e6080e7          	jalr	1254(ra) # 80000b68 <release>
  }
}
    8000468a:	70e2                	ld	ra,56(sp)
    8000468c:	7442                	ld	s0,48(sp)
    8000468e:	74a2                	ld	s1,40(sp)
    80004690:	7902                	ld	s2,32(sp)
    80004692:	69e2                	ld	s3,24(sp)
    80004694:	6a42                	ld	s4,16(sp)
    80004696:	6aa2                	ld	s5,8(sp)
    80004698:	6121                	addi	sp,sp,64
    8000469a:	8082                	ret
    pipeclose(ff.pipe, ff.writable);
    8000469c:	85d6                	mv	a1,s5
    8000469e:	8552                	mv	a0,s4
    800046a0:	00000097          	auipc	ra,0x0
    800046a4:	348080e7          	jalr	840(ra) # 800049e8 <pipeclose>
    800046a8:	b7cd                	j	8000468a <fileclose+0xb0>

00000000800046aa <filestat>:

// Get metadata about file f.
// addr is a user virtual address, pointing to a struct stat.
int
filestat(struct file *f, uint64 addr)
{
    800046aa:	715d                	addi	sp,sp,-80
    800046ac:	e486                	sd	ra,72(sp)
    800046ae:	e0a2                	sd	s0,64(sp)
    800046b0:	fc26                	sd	s1,56(sp)
    800046b2:	f84a                	sd	s2,48(sp)
    800046b4:	f44e                	sd	s3,40(sp)
    800046b6:	0880                	addi	s0,sp,80
    800046b8:	84aa                	mv	s1,a0
    800046ba:	89ae                	mv	s3,a1
  struct proc *p = myproc();
    800046bc:	ffffd097          	auipc	ra,0xffffd
    800046c0:	1e2080e7          	jalr	482(ra) # 8000189e <myproc>
  struct stat st;
  
  if(f->type == FD_INODE || f->type == FD_DEVICE){
    800046c4:	409c                	lw	a5,0(s1)
    800046c6:	37f9                	addiw	a5,a5,-2
    800046c8:	4705                	li	a4,1
    800046ca:	04f76763          	bltu	a4,a5,80004718 <filestat+0x6e>
    800046ce:	892a                	mv	s2,a0
    ilock(f->ip);
    800046d0:	6c88                	ld	a0,24(s1)
    800046d2:	fffff097          	auipc	ra,0xfffff
    800046d6:	dfe080e7          	jalr	-514(ra) # 800034d0 <ilock>
    stati(f->ip, &st);
    800046da:	fb840593          	addi	a1,s0,-72
    800046de:	6c88                	ld	a0,24(s1)
    800046e0:	fffff097          	auipc	ra,0xfffff
    800046e4:	058080e7          	jalr	88(ra) # 80003738 <stati>
    iunlock(f->ip);
    800046e8:	6c88                	ld	a0,24(s1)
    800046ea:	fffff097          	auipc	ra,0xfffff
    800046ee:	eaa080e7          	jalr	-342(ra) # 80003594 <iunlock>
    if(copyout(p->pagetable, addr, (char *)&st, sizeof(st)) < 0)
    800046f2:	46e1                	li	a3,24
    800046f4:	fb840613          	addi	a2,s0,-72
    800046f8:	85ce                	mv	a1,s3
    800046fa:	04893503          	ld	a0,72(s2)
    800046fe:	ffffd097          	auipc	ra,0xffffd
    80004702:	eae080e7          	jalr	-338(ra) # 800015ac <copyout>
    80004706:	41f5551b          	sraiw	a0,a0,0x1f
      return -1;
    return 0;
  }
  return -1;
}
    8000470a:	60a6                	ld	ra,72(sp)
    8000470c:	6406                	ld	s0,64(sp)
    8000470e:	74e2                	ld	s1,56(sp)
    80004710:	7942                	ld	s2,48(sp)
    80004712:	79a2                	ld	s3,40(sp)
    80004714:	6161                	addi	sp,sp,80
    80004716:	8082                	ret
  return -1;
    80004718:	557d                	li	a0,-1
    8000471a:	bfc5                	j	8000470a <filestat+0x60>

000000008000471c <fileread>:

// Read from file f.
// addr is a user virtual address.
int
fileread(struct file *f, uint64 addr, int n)
{
    8000471c:	7179                	addi	sp,sp,-48
    8000471e:	f406                	sd	ra,40(sp)
    80004720:	f022                	sd	s0,32(sp)
    80004722:	ec26                	sd	s1,24(sp)
    80004724:	e84a                	sd	s2,16(sp)
    80004726:	e44e                	sd	s3,8(sp)
    80004728:	1800                	addi	s0,sp,48
  int r = 0;

  if(f->readable == 0)
    8000472a:	00854783          	lbu	a5,8(a0)
    8000472e:	cfc1                	beqz	a5,800047c6 <fileread+0xaa>
    80004730:	89b2                	mv	s3,a2
    80004732:	892e                	mv	s2,a1
    80004734:	84aa                	mv	s1,a0
    return -1;

  if(f->type == FD_PIPE){
    80004736:	411c                	lw	a5,0(a0)
    80004738:	4705                	li	a4,1
    8000473a:	04e78963          	beq	a5,a4,8000478c <fileread+0x70>
    r = piperead(f->pipe, addr, n);
  } else if(f->type == FD_DEVICE){
    8000473e:	470d                	li	a4,3
    80004740:	04e78d63          	beq	a5,a4,8000479a <fileread+0x7e>
    r = devsw[f->major].read(1, addr, n);
  } else if(f->type == FD_INODE){
    80004744:	4709                	li	a4,2
    80004746:	06e79863          	bne	a5,a4,800047b6 <fileread+0x9a>
    ilock(f->ip);
    8000474a:	6d08                	ld	a0,24(a0)
    8000474c:	fffff097          	auipc	ra,0xfffff
    80004750:	d84080e7          	jalr	-636(ra) # 800034d0 <ilock>
    if((r = readi(f->ip, 1, addr, f->off, n)) > 0)
    80004754:	874e                	mv	a4,s3
    80004756:	5094                	lw	a3,32(s1)
    80004758:	864a                	mv	a2,s2
    8000475a:	4585                	li	a1,1
    8000475c:	6c88                	ld	a0,24(s1)
    8000475e:	fffff097          	auipc	ra,0xfffff
    80004762:	004080e7          	jalr	4(ra) # 80003762 <readi>
    80004766:	892a                	mv	s2,a0
    80004768:	00a05563          	blez	a0,80004772 <fileread+0x56>
      f->off += r;
    8000476c:	509c                	lw	a5,32(s1)
    8000476e:	9fa9                	addw	a5,a5,a0
    80004770:	d09c                	sw	a5,32(s1)
    iunlock(f->ip);
    80004772:	6c88                	ld	a0,24(s1)
    80004774:	fffff097          	auipc	ra,0xfffff
    80004778:	e20080e7          	jalr	-480(ra) # 80003594 <iunlock>
  } else {
    panic("fileread");
  }

  return r;
}
    8000477c:	854a                	mv	a0,s2
    8000477e:	70a2                	ld	ra,40(sp)
    80004780:	7402                	ld	s0,32(sp)
    80004782:	64e2                	ld	s1,24(sp)
    80004784:	6942                	ld	s2,16(sp)
    80004786:	69a2                	ld	s3,8(sp)
    80004788:	6145                	addi	sp,sp,48
    8000478a:	8082                	ret
    r = piperead(f->pipe, addr, n);
    8000478c:	6908                	ld	a0,16(a0)
    8000478e:	00000097          	auipc	ra,0x0
    80004792:	3e4080e7          	jalr	996(ra) # 80004b72 <piperead>
    80004796:	892a                	mv	s2,a0
    80004798:	b7d5                	j	8000477c <fileread+0x60>
    r = devsw[f->major].read(1, addr, n);
    8000479a:	02451783          	lh	a5,36(a0)
    8000479e:	00479713          	slli	a4,a5,0x4
    800047a2:	0001d797          	auipc	a5,0x1d
    800047a6:	14678793          	addi	a5,a5,326 # 800218e8 <devsw>
    800047aa:	97ba                	add	a5,a5,a4
    800047ac:	639c                	ld	a5,0(a5)
    800047ae:	4505                	li	a0,1
    800047b0:	9782                	jalr	a5
    800047b2:	892a                	mv	s2,a0
    800047b4:	b7e1                	j	8000477c <fileread+0x60>
    panic("fileread");
    800047b6:	00003517          	auipc	a0,0x3
    800047ba:	f6250513          	addi	a0,a0,-158 # 80007718 <userret+0x688>
    800047be:	ffffc097          	auipc	ra,0xffffc
    800047c2:	dc0080e7          	jalr	-576(ra) # 8000057e <panic>
    return -1;
    800047c6:	597d                	li	s2,-1
    800047c8:	bf55                	j	8000477c <fileread+0x60>

00000000800047ca <filewrite>:
int
filewrite(struct file *f, uint64 addr, int n)
{
  int r, ret = 0;

  if(f->writable == 0)
    800047ca:	00954783          	lbu	a5,9(a0)
    800047ce:	12078e63          	beqz	a5,8000490a <filewrite+0x140>
{
    800047d2:	715d                	addi	sp,sp,-80
    800047d4:	e486                	sd	ra,72(sp)
    800047d6:	e0a2                	sd	s0,64(sp)
    800047d8:	fc26                	sd	s1,56(sp)
    800047da:	f84a                	sd	s2,48(sp)
    800047dc:	f44e                	sd	s3,40(sp)
    800047de:	f052                	sd	s4,32(sp)
    800047e0:	ec56                	sd	s5,24(sp)
    800047e2:	e85a                	sd	s6,16(sp)
    800047e4:	e45e                	sd	s7,8(sp)
    800047e6:	e062                	sd	s8,0(sp)
    800047e8:	0880                	addi	s0,sp,80
    800047ea:	8ab2                	mv	s5,a2
    800047ec:	8b2e                	mv	s6,a1
    800047ee:	84aa                	mv	s1,a0
    return -1;

  if(f->type == FD_PIPE){
    800047f0:	411c                	lw	a5,0(a0)
    800047f2:	4705                	li	a4,1
    800047f4:	02e78263          	beq	a5,a4,80004818 <filewrite+0x4e>
    ret = pipewrite(f->pipe, addr, n);
  } else if(f->type == FD_DEVICE){
    800047f8:	470d                	li	a4,3
    800047fa:	02e78563          	beq	a5,a4,80004824 <filewrite+0x5a>
    ret = devsw[f->major].write(1, addr, n);
  } else if(f->type == FD_INODE){
    800047fe:	4709                	li	a4,2
    80004800:	0ee79d63          	bne	a5,a4,800048fa <filewrite+0x130>
    // and 2 blocks of slop for non-aligned writes.
    // this really belongs lower down, since writei()
    // might be writing a device like the console.
    int max = ((MAXOPBLOCKS-1-1-2) / 2) * BSIZE;
    int i = 0;
    while(i < n){
    80004804:	0ec05763          	blez	a2,800048f2 <filewrite+0x128>
    int i = 0;
    80004808:	4901                	li	s2,0
    8000480a:	6b85                	lui	s7,0x1
    8000480c:	c00b8b93          	addi	s7,s7,-1024 # c00 <_entry-0x7ffff400>
    80004810:	6c05                	lui	s8,0x1
    80004812:	c00c0c1b          	addiw	s8,s8,-1024
    80004816:	a051                	j	8000489a <filewrite+0xd0>
    ret = pipewrite(f->pipe, addr, n);
    80004818:	6908                	ld	a0,16(a0)
    8000481a:	00000097          	auipc	ra,0x0
    8000481e:	23e080e7          	jalr	574(ra) # 80004a58 <pipewrite>
    80004822:	a065                	j	800048ca <filewrite+0x100>
    ret = devsw[f->major].write(1, addr, n);
    80004824:	02451783          	lh	a5,36(a0)
    80004828:	00479713          	slli	a4,a5,0x4
    8000482c:	0001d797          	auipc	a5,0x1d
    80004830:	0bc78793          	addi	a5,a5,188 # 800218e8 <devsw>
    80004834:	97ba                	add	a5,a5,a4
    80004836:	679c                	ld	a5,8(a5)
    80004838:	4505                	li	a0,1
    8000483a:	9782                	jalr	a5
    8000483c:	a079                	j	800048ca <filewrite+0x100>
    8000483e:	00098a1b          	sext.w	s4,s3
      int n1 = n - i;
      if(n1 > max)
        n1 = max;

      begin_op(f->ip->dev);
    80004842:	6c9c                	ld	a5,24(s1)
    80004844:	4388                	lw	a0,0(a5)
    80004846:	fffff097          	auipc	ra,0xfffff
    8000484a:	73a080e7          	jalr	1850(ra) # 80003f80 <begin_op>
      ilock(f->ip);
    8000484e:	6c88                	ld	a0,24(s1)
    80004850:	fffff097          	auipc	ra,0xfffff
    80004854:	c80080e7          	jalr	-896(ra) # 800034d0 <ilock>
      if ((r = writei(f->ip, 1, addr + i, f->off, n1)) > 0)
    80004858:	8752                	mv	a4,s4
    8000485a:	5094                	lw	a3,32(s1)
    8000485c:	01690633          	add	a2,s2,s6
    80004860:	4585                	li	a1,1
    80004862:	6c88                	ld	a0,24(s1)
    80004864:	fffff097          	auipc	ra,0xfffff
    80004868:	ff2080e7          	jalr	-14(ra) # 80003856 <writei>
    8000486c:	89aa                	mv	s3,a0
    8000486e:	02a05e63          	blez	a0,800048aa <filewrite+0xe0>
        f->off += r;
    80004872:	509c                	lw	a5,32(s1)
    80004874:	9fa9                	addw	a5,a5,a0
    80004876:	d09c                	sw	a5,32(s1)
      iunlock(f->ip);
    80004878:	6c88                	ld	a0,24(s1)
    8000487a:	fffff097          	auipc	ra,0xfffff
    8000487e:	d1a080e7          	jalr	-742(ra) # 80003594 <iunlock>
      end_op(f->ip->dev);
    80004882:	6c9c                	ld	a5,24(s1)
    80004884:	4388                	lw	a0,0(a5)
    80004886:	fffff097          	auipc	ra,0xfffff
    8000488a:	7a4080e7          	jalr	1956(ra) # 8000402a <end_op>

      if(r < 0)
        break;
      if(r != n1)
    8000488e:	05499a63          	bne	s3,s4,800048e2 <filewrite+0x118>
        panic("short filewrite");
      i += r;
    80004892:	012a093b          	addw	s2,s4,s2
    while(i < n){
    80004896:	03595763          	ble	s5,s2,800048c4 <filewrite+0xfa>
      int n1 = n - i;
    8000489a:	412a87bb          	subw	a5,s5,s2
      if(n1 > max)
    8000489e:	89be                	mv	s3,a5
    800048a0:	2781                	sext.w	a5,a5
    800048a2:	f8fbdee3          	ble	a5,s7,8000483e <filewrite+0x74>
    800048a6:	89e2                	mv	s3,s8
    800048a8:	bf59                	j	8000483e <filewrite+0x74>
      iunlock(f->ip);
    800048aa:	6c88                	ld	a0,24(s1)
    800048ac:	fffff097          	auipc	ra,0xfffff
    800048b0:	ce8080e7          	jalr	-792(ra) # 80003594 <iunlock>
      end_op(f->ip->dev);
    800048b4:	6c9c                	ld	a5,24(s1)
    800048b6:	4388                	lw	a0,0(a5)
    800048b8:	fffff097          	auipc	ra,0xfffff
    800048bc:	772080e7          	jalr	1906(ra) # 8000402a <end_op>
      if(r < 0)
    800048c0:	fc09d7e3          	bgez	s3,8000488e <filewrite+0xc4>
    }
    ret = (i == n ? n : -1);
    800048c4:	8556                	mv	a0,s5
    800048c6:	032a9863          	bne	s5,s2,800048f6 <filewrite+0x12c>
  } else {
    panic("filewrite");
  }

  return ret;
}
    800048ca:	60a6                	ld	ra,72(sp)
    800048cc:	6406                	ld	s0,64(sp)
    800048ce:	74e2                	ld	s1,56(sp)
    800048d0:	7942                	ld	s2,48(sp)
    800048d2:	79a2                	ld	s3,40(sp)
    800048d4:	7a02                	ld	s4,32(sp)
    800048d6:	6ae2                	ld	s5,24(sp)
    800048d8:	6b42                	ld	s6,16(sp)
    800048da:	6ba2                	ld	s7,8(sp)
    800048dc:	6c02                	ld	s8,0(sp)
    800048de:	6161                	addi	sp,sp,80
    800048e0:	8082                	ret
        panic("short filewrite");
    800048e2:	00003517          	auipc	a0,0x3
    800048e6:	e4650513          	addi	a0,a0,-442 # 80007728 <userret+0x698>
    800048ea:	ffffc097          	auipc	ra,0xffffc
    800048ee:	c94080e7          	jalr	-876(ra) # 8000057e <panic>
    int i = 0;
    800048f2:	4901                	li	s2,0
    800048f4:	bfc1                	j	800048c4 <filewrite+0xfa>
    ret = (i == n ? n : -1);
    800048f6:	557d                	li	a0,-1
    800048f8:	bfc9                	j	800048ca <filewrite+0x100>
    panic("filewrite");
    800048fa:	00003517          	auipc	a0,0x3
    800048fe:	e3e50513          	addi	a0,a0,-450 # 80007738 <userret+0x6a8>
    80004902:	ffffc097          	auipc	ra,0xffffc
    80004906:	c7c080e7          	jalr	-900(ra) # 8000057e <panic>
    return -1;
    8000490a:	557d                	li	a0,-1
}
    8000490c:	8082                	ret

000000008000490e <pipealloc>:
  int writeopen;  // write fd is still open
};

int
pipealloc(struct file **f0, struct file **f1)
{
    8000490e:	7179                	addi	sp,sp,-48
    80004910:	f406                	sd	ra,40(sp)
    80004912:	f022                	sd	s0,32(sp)
    80004914:	ec26                	sd	s1,24(sp)
    80004916:	e84a                	sd	s2,16(sp)
    80004918:	e44e                	sd	s3,8(sp)
    8000491a:	e052                	sd	s4,0(sp)
    8000491c:	1800                	addi	s0,sp,48
    8000491e:	84aa                	mv	s1,a0
    80004920:	892e                	mv	s2,a1
  struct pipe *pi;

  pi = 0;
  *f0 = *f1 = 0;
    80004922:	0005b023          	sd	zero,0(a1)
    80004926:	00053023          	sd	zero,0(a0)
  if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0)
    8000492a:	00000097          	auipc	ra,0x0
    8000492e:	be0080e7          	jalr	-1056(ra) # 8000450a <filealloc>
    80004932:	e088                	sd	a0,0(s1)
    80004934:	c551                	beqz	a0,800049c0 <pipealloc+0xb2>
    80004936:	00000097          	auipc	ra,0x0
    8000493a:	bd4080e7          	jalr	-1068(ra) # 8000450a <filealloc>
    8000493e:	00a93023          	sd	a0,0(s2)
    80004942:	c92d                	beqz	a0,800049b4 <pipealloc+0xa6>
    goto bad;
  if((pi = (struct pipe*)kalloc()) == 0)
    80004944:	ffffc097          	auipc	ra,0xffffc
    80004948:	04e080e7          	jalr	78(ra) # 80000992 <kalloc>
    8000494c:	89aa                	mv	s3,a0
    8000494e:	c125                	beqz	a0,800049ae <pipealloc+0xa0>
    goto bad;
  pi->readopen = 1;
    80004950:	4a05                	li	s4,1
    80004952:	23452023          	sw	s4,544(a0)
  pi->writeopen = 1;
    80004956:	23452223          	sw	s4,548(a0)
  pi->nwrite = 0;
    8000495a:	20052e23          	sw	zero,540(a0)
  pi->nread = 0;
    8000495e:	20052c23          	sw	zero,536(a0)
  initlock(&pi->lock, "pipe");
    80004962:	00003597          	auipc	a1,0x3
    80004966:	de658593          	addi	a1,a1,-538 # 80007748 <userret+0x6b8>
    8000496a:	ffffc097          	auipc	ra,0xffffc
    8000496e:	088080e7          	jalr	136(ra) # 800009f2 <initlock>
  (*f0)->type = FD_PIPE;
    80004972:	609c                	ld	a5,0(s1)
    80004974:	0147a023          	sw	s4,0(a5)
  (*f0)->readable = 1;
    80004978:	609c                	ld	a5,0(s1)
    8000497a:	01478423          	sb	s4,8(a5)
  (*f0)->writable = 0;
    8000497e:	609c                	ld	a5,0(s1)
    80004980:	000784a3          	sb	zero,9(a5)
  (*f0)->pipe = pi;
    80004984:	609c                	ld	a5,0(s1)
    80004986:	0137b823          	sd	s3,16(a5)
  (*f1)->type = FD_PIPE;
    8000498a:	00093783          	ld	a5,0(s2)
    8000498e:	0147a023          	sw	s4,0(a5)
  (*f1)->readable = 0;
    80004992:	00093783          	ld	a5,0(s2)
    80004996:	00078423          	sb	zero,8(a5)
  (*f1)->writable = 1;
    8000499a:	00093783          	ld	a5,0(s2)
    8000499e:	014784a3          	sb	s4,9(a5)
  (*f1)->pipe = pi;
    800049a2:	00093783          	ld	a5,0(s2)
    800049a6:	0137b823          	sd	s3,16(a5)
  return 0;
    800049aa:	4501                	li	a0,0
    800049ac:	a025                	j	800049d4 <pipealloc+0xc6>

 bad:
  if(pi)
    kfree((char*)pi);
  if(*f0)
    800049ae:	6088                	ld	a0,0(s1)
    800049b0:	e501                	bnez	a0,800049b8 <pipealloc+0xaa>
    800049b2:	a039                	j	800049c0 <pipealloc+0xb2>
    800049b4:	6088                	ld	a0,0(s1)
    800049b6:	c51d                	beqz	a0,800049e4 <pipealloc+0xd6>
    fileclose(*f0);
    800049b8:	00000097          	auipc	ra,0x0
    800049bc:	c22080e7          	jalr	-990(ra) # 800045da <fileclose>
  if(*f1)
    800049c0:	00093783          	ld	a5,0(s2)
    fileclose(*f1);
  return -1;
    800049c4:	557d                	li	a0,-1
  if(*f1)
    800049c6:	c799                	beqz	a5,800049d4 <pipealloc+0xc6>
    fileclose(*f1);
    800049c8:	853e                	mv	a0,a5
    800049ca:	00000097          	auipc	ra,0x0
    800049ce:	c10080e7          	jalr	-1008(ra) # 800045da <fileclose>
  return -1;
    800049d2:	557d                	li	a0,-1
}
    800049d4:	70a2                	ld	ra,40(sp)
    800049d6:	7402                	ld	s0,32(sp)
    800049d8:	64e2                	ld	s1,24(sp)
    800049da:	6942                	ld	s2,16(sp)
    800049dc:	69a2                	ld	s3,8(sp)
    800049de:	6a02                	ld	s4,0(sp)
    800049e0:	6145                	addi	sp,sp,48
    800049e2:	8082                	ret
  return -1;
    800049e4:	557d                	li	a0,-1
    800049e6:	b7fd                	j	800049d4 <pipealloc+0xc6>

00000000800049e8 <pipeclose>:

void
pipeclose(struct pipe *pi, int writable)
{
    800049e8:	1101                	addi	sp,sp,-32
    800049ea:	ec06                	sd	ra,24(sp)
    800049ec:	e822                	sd	s0,16(sp)
    800049ee:	e426                	sd	s1,8(sp)
    800049f0:	e04a                	sd	s2,0(sp)
    800049f2:	1000                	addi	s0,sp,32
    800049f4:	84aa                	mv	s1,a0
    800049f6:	892e                	mv	s2,a1
  acquire(&pi->lock);
    800049f8:	ffffc097          	auipc	ra,0xffffc
    800049fc:	108080e7          	jalr	264(ra) # 80000b00 <acquire>
  if(writable){
    80004a00:	02090d63          	beqz	s2,80004a3a <pipeclose+0x52>
    pi->writeopen = 0;
    80004a04:	2204a223          	sw	zero,548(s1)
    wakeup(&pi->nread);
    80004a08:	21848513          	addi	a0,s1,536
    80004a0c:	ffffd097          	auipc	ra,0xffffd
    80004a10:	7ec080e7          	jalr	2028(ra) # 800021f8 <wakeup>
  } else {
    pi->readopen = 0;
    wakeup(&pi->nwrite);
  }
  if(pi->readopen == 0 && pi->writeopen == 0){
    80004a14:	2204b783          	ld	a5,544(s1)
    80004a18:	eb95                	bnez	a5,80004a4c <pipeclose+0x64>
    release(&pi->lock);
    80004a1a:	8526                	mv	a0,s1
    80004a1c:	ffffc097          	auipc	ra,0xffffc
    80004a20:	14c080e7          	jalr	332(ra) # 80000b68 <release>
    kfree((char*)pi);
    80004a24:	8526                	mv	a0,s1
    80004a26:	ffffc097          	auipc	ra,0xffffc
    80004a2a:	e6e080e7          	jalr	-402(ra) # 80000894 <kfree>
  } else
    release(&pi->lock);
}
    80004a2e:	60e2                	ld	ra,24(sp)
    80004a30:	6442                	ld	s0,16(sp)
    80004a32:	64a2                	ld	s1,8(sp)
    80004a34:	6902                	ld	s2,0(sp)
    80004a36:	6105                	addi	sp,sp,32
    80004a38:	8082                	ret
    pi->readopen = 0;
    80004a3a:	2204a023          	sw	zero,544(s1)
    wakeup(&pi->nwrite);
    80004a3e:	21c48513          	addi	a0,s1,540
    80004a42:	ffffd097          	auipc	ra,0xffffd
    80004a46:	7b6080e7          	jalr	1974(ra) # 800021f8 <wakeup>
    80004a4a:	b7e9                	j	80004a14 <pipeclose+0x2c>
    release(&pi->lock);
    80004a4c:	8526                	mv	a0,s1
    80004a4e:	ffffc097          	auipc	ra,0xffffc
    80004a52:	11a080e7          	jalr	282(ra) # 80000b68 <release>
}
    80004a56:	bfe1                	j	80004a2e <pipeclose+0x46>

0000000080004a58 <pipewrite>:

int
pipewrite(struct pipe *pi, uint64 addr, int n)
{
    80004a58:	7159                	addi	sp,sp,-112
    80004a5a:	f486                	sd	ra,104(sp)
    80004a5c:	f0a2                	sd	s0,96(sp)
    80004a5e:	eca6                	sd	s1,88(sp)
    80004a60:	e8ca                	sd	s2,80(sp)
    80004a62:	e4ce                	sd	s3,72(sp)
    80004a64:	e0d2                	sd	s4,64(sp)
    80004a66:	fc56                	sd	s5,56(sp)
    80004a68:	f85a                	sd	s6,48(sp)
    80004a6a:	f45e                	sd	s7,40(sp)
    80004a6c:	f062                	sd	s8,32(sp)
    80004a6e:	ec66                	sd	s9,24(sp)
    80004a70:	1880                	addi	s0,sp,112
    80004a72:	84aa                	mv	s1,a0
    80004a74:	8bae                	mv	s7,a1
    80004a76:	8b32                	mv	s6,a2
  int i;
  char ch;
  struct proc *pr = myproc();
    80004a78:	ffffd097          	auipc	ra,0xffffd
    80004a7c:	e26080e7          	jalr	-474(ra) # 8000189e <myproc>
    80004a80:	8c2a                	mv	s8,a0

  acquire(&pi->lock);
    80004a82:	8526                	mv	a0,s1
    80004a84:	ffffc097          	auipc	ra,0xffffc
    80004a88:	07c080e7          	jalr	124(ra) # 80000b00 <acquire>
  for(i = 0; i < n; i++){
    80004a8c:	0d605663          	blez	s6,80004b58 <pipewrite+0x100>
    80004a90:	8926                	mv	s2,s1
    80004a92:	fffb0a9b          	addiw	s5,s6,-1
    80004a96:	1a82                	slli	s5,s5,0x20
    80004a98:	020ada93          	srli	s5,s5,0x20
    80004a9c:	001b8793          	addi	a5,s7,1
    80004aa0:	9abe                	add	s5,s5,a5
    while(pi->nwrite == pi->nread + PIPESIZE){  //DOC: pipewrite-full
      if(pi->readopen == 0 || myproc()->killed){
        release(&pi->lock);
        return -1;
      }
      wakeup(&pi->nread);
    80004aa2:	21848a13          	addi	s4,s1,536
      sleep(&pi->nwrite, &pi->lock);
    80004aa6:	21c48993          	addi	s3,s1,540
    }
    if(copyin(pr->pagetable, &ch, addr + i, 1) == -1)
    80004aaa:	5cfd                	li	s9,-1
    while(pi->nwrite == pi->nread + PIPESIZE){  //DOC: pipewrite-full
    80004aac:	2184a783          	lw	a5,536(s1)
    80004ab0:	21c4a703          	lw	a4,540(s1)
    80004ab4:	2007879b          	addiw	a5,a5,512
    80004ab8:	06f71463          	bne	a4,a5,80004b20 <pipewrite+0xc8>
      if(pi->readopen == 0 || myproc()->killed){
    80004abc:	2204a783          	lw	a5,544(s1)
    80004ac0:	cf8d                	beqz	a5,80004afa <pipewrite+0xa2>
    80004ac2:	ffffd097          	auipc	ra,0xffffd
    80004ac6:	ddc080e7          	jalr	-548(ra) # 8000189e <myproc>
    80004aca:	591c                	lw	a5,48(a0)
    80004acc:	e79d                	bnez	a5,80004afa <pipewrite+0xa2>
      wakeup(&pi->nread);
    80004ace:	8552                	mv	a0,s4
    80004ad0:	ffffd097          	auipc	ra,0xffffd
    80004ad4:	728080e7          	jalr	1832(ra) # 800021f8 <wakeup>
      sleep(&pi->nwrite, &pi->lock);
    80004ad8:	85ca                	mv	a1,s2
    80004ada:	854e                	mv	a0,s3
    80004adc:	ffffd097          	auipc	ra,0xffffd
    80004ae0:	5d0080e7          	jalr	1488(ra) # 800020ac <sleep>
    while(pi->nwrite == pi->nread + PIPESIZE){  //DOC: pipewrite-full
    80004ae4:	2184a783          	lw	a5,536(s1)
    80004ae8:	21c4a703          	lw	a4,540(s1)
    80004aec:	2007879b          	addiw	a5,a5,512
    80004af0:	02f71863          	bne	a4,a5,80004b20 <pipewrite+0xc8>
      if(pi->readopen == 0 || myproc()->killed){
    80004af4:	2204a783          	lw	a5,544(s1)
    80004af8:	f7e9                	bnez	a5,80004ac2 <pipewrite+0x6a>
        release(&pi->lock);
    80004afa:	8526                	mv	a0,s1
    80004afc:	ffffc097          	auipc	ra,0xffffc
    80004b00:	06c080e7          	jalr	108(ra) # 80000b68 <release>
        return -1;
    80004b04:	557d                	li	a0,-1
    pi->data[pi->nwrite++ % PIPESIZE] = ch;
  }
  wakeup(&pi->nread);
  release(&pi->lock);
  return n;
}
    80004b06:	70a6                	ld	ra,104(sp)
    80004b08:	7406                	ld	s0,96(sp)
    80004b0a:	64e6                	ld	s1,88(sp)
    80004b0c:	6946                	ld	s2,80(sp)
    80004b0e:	69a6                	ld	s3,72(sp)
    80004b10:	6a06                	ld	s4,64(sp)
    80004b12:	7ae2                	ld	s5,56(sp)
    80004b14:	7b42                	ld	s6,48(sp)
    80004b16:	7ba2                	ld	s7,40(sp)
    80004b18:	7c02                	ld	s8,32(sp)
    80004b1a:	6ce2                	ld	s9,24(sp)
    80004b1c:	6165                	addi	sp,sp,112
    80004b1e:	8082                	ret
    if(copyin(pr->pagetable, &ch, addr + i, 1) == -1)
    80004b20:	4685                	li	a3,1
    80004b22:	865e                	mv	a2,s7
    80004b24:	f9f40593          	addi	a1,s0,-97
    80004b28:	048c3503          	ld	a0,72(s8) # 1048 <_entry-0x7fffefb8>
    80004b2c:	ffffd097          	auipc	ra,0xffffd
    80004b30:	b12080e7          	jalr	-1262(ra) # 8000163e <copyin>
    80004b34:	03950263          	beq	a0,s9,80004b58 <pipewrite+0x100>
    pi->data[pi->nwrite++ % PIPESIZE] = ch;
    80004b38:	21c4a783          	lw	a5,540(s1)
    80004b3c:	0017871b          	addiw	a4,a5,1
    80004b40:	20e4ae23          	sw	a4,540(s1)
    80004b44:	1ff7f793          	andi	a5,a5,511
    80004b48:	97a6                	add	a5,a5,s1
    80004b4a:	f9f44703          	lbu	a4,-97(s0)
    80004b4e:	00e78c23          	sb	a4,24(a5)
  for(i = 0; i < n; i++){
    80004b52:	0b85                	addi	s7,s7,1
    80004b54:	f55b9ce3          	bne	s7,s5,80004aac <pipewrite+0x54>
  wakeup(&pi->nread);
    80004b58:	21848513          	addi	a0,s1,536
    80004b5c:	ffffd097          	auipc	ra,0xffffd
    80004b60:	69c080e7          	jalr	1692(ra) # 800021f8 <wakeup>
  release(&pi->lock);
    80004b64:	8526                	mv	a0,s1
    80004b66:	ffffc097          	auipc	ra,0xffffc
    80004b6a:	002080e7          	jalr	2(ra) # 80000b68 <release>
  return n;
    80004b6e:	855a                	mv	a0,s6
    80004b70:	bf59                	j	80004b06 <pipewrite+0xae>

0000000080004b72 <piperead>:

int
piperead(struct pipe *pi, uint64 addr, int n)
{
    80004b72:	715d                	addi	sp,sp,-80
    80004b74:	e486                	sd	ra,72(sp)
    80004b76:	e0a2                	sd	s0,64(sp)
    80004b78:	fc26                	sd	s1,56(sp)
    80004b7a:	f84a                	sd	s2,48(sp)
    80004b7c:	f44e                	sd	s3,40(sp)
    80004b7e:	f052                	sd	s4,32(sp)
    80004b80:	ec56                	sd	s5,24(sp)
    80004b82:	e85a                	sd	s6,16(sp)
    80004b84:	0880                	addi	s0,sp,80
    80004b86:	84aa                	mv	s1,a0
    80004b88:	89ae                	mv	s3,a1
    80004b8a:	8a32                	mv	s4,a2
  int i;
  struct proc *pr = myproc();
    80004b8c:	ffffd097          	auipc	ra,0xffffd
    80004b90:	d12080e7          	jalr	-750(ra) # 8000189e <myproc>
    80004b94:	8aaa                	mv	s5,a0
  char ch;

  acquire(&pi->lock);
    80004b96:	8526                	mv	a0,s1
    80004b98:	ffffc097          	auipc	ra,0xffffc
    80004b9c:	f68080e7          	jalr	-152(ra) # 80000b00 <acquire>
  while(pi->nread == pi->nwrite && pi->writeopen){  //DOC: pipe-empty
    80004ba0:	2184a703          	lw	a4,536(s1)
    80004ba4:	21c4a783          	lw	a5,540(s1)
    80004ba8:	06f71b63          	bne	a4,a5,80004c1e <piperead+0xac>
    80004bac:	8926                	mv	s2,s1
    80004bae:	2244a783          	lw	a5,548(s1)
    80004bb2:	cb85                	beqz	a5,80004be2 <piperead+0x70>
    if(myproc()->killed){
      release(&pi->lock);
      return -1;
    }
    sleep(&pi->nread, &pi->lock); //DOC: piperead-sleep
    80004bb4:	21848b13          	addi	s6,s1,536
    if(myproc()->killed){
    80004bb8:	ffffd097          	auipc	ra,0xffffd
    80004bbc:	ce6080e7          	jalr	-794(ra) # 8000189e <myproc>
    80004bc0:	591c                	lw	a5,48(a0)
    80004bc2:	e7b9                	bnez	a5,80004c10 <piperead+0x9e>
    sleep(&pi->nread, &pi->lock); //DOC: piperead-sleep
    80004bc4:	85ca                	mv	a1,s2
    80004bc6:	855a                	mv	a0,s6
    80004bc8:	ffffd097          	auipc	ra,0xffffd
    80004bcc:	4e4080e7          	jalr	1252(ra) # 800020ac <sleep>
  while(pi->nread == pi->nwrite && pi->writeopen){  //DOC: pipe-empty
    80004bd0:	2184a703          	lw	a4,536(s1)
    80004bd4:	21c4a783          	lw	a5,540(s1)
    80004bd8:	04f71363          	bne	a4,a5,80004c1e <piperead+0xac>
    80004bdc:	2244a783          	lw	a5,548(s1)
    80004be0:	ffe1                	bnez	a5,80004bb8 <piperead+0x46>
  }
  for(i = 0; i < n; i++){  //DOC: piperead-copy
    if(pi->nread == pi->nwrite)
    80004be2:	4901                	li	s2,0
      break;
    ch = pi->data[pi->nread++ % PIPESIZE];
    if(copyout(pr->pagetable, addr + i, &ch, 1) == -1)
      break;
  }
  wakeup(&pi->nwrite);  //DOC: piperead-wakeup
    80004be4:	21c48513          	addi	a0,s1,540
    80004be8:	ffffd097          	auipc	ra,0xffffd
    80004bec:	610080e7          	jalr	1552(ra) # 800021f8 <wakeup>
  release(&pi->lock);
    80004bf0:	8526                	mv	a0,s1
    80004bf2:	ffffc097          	auipc	ra,0xffffc
    80004bf6:	f76080e7          	jalr	-138(ra) # 80000b68 <release>
  return i;
}
    80004bfa:	854a                	mv	a0,s2
    80004bfc:	60a6                	ld	ra,72(sp)
    80004bfe:	6406                	ld	s0,64(sp)
    80004c00:	74e2                	ld	s1,56(sp)
    80004c02:	7942                	ld	s2,48(sp)
    80004c04:	79a2                	ld	s3,40(sp)
    80004c06:	7a02                	ld	s4,32(sp)
    80004c08:	6ae2                	ld	s5,24(sp)
    80004c0a:	6b42                	ld	s6,16(sp)
    80004c0c:	6161                	addi	sp,sp,80
    80004c0e:	8082                	ret
      release(&pi->lock);
    80004c10:	8526                	mv	a0,s1
    80004c12:	ffffc097          	auipc	ra,0xffffc
    80004c16:	f56080e7          	jalr	-170(ra) # 80000b68 <release>
      return -1;
    80004c1a:	597d                	li	s2,-1
    80004c1c:	bff9                	j	80004bfa <piperead+0x88>
  for(i = 0; i < n; i++){  //DOC: piperead-copy
    80004c1e:	4901                	li	s2,0
    80004c20:	fd4052e3          	blez	s4,80004be4 <piperead+0x72>
    if(pi->nread == pi->nwrite)
    80004c24:	2184a783          	lw	a5,536(s1)
    80004c28:	4901                	li	s2,0
    if(copyout(pr->pagetable, addr + i, &ch, 1) == -1)
    80004c2a:	5b7d                	li	s6,-1
    ch = pi->data[pi->nread++ % PIPESIZE];
    80004c2c:	0017871b          	addiw	a4,a5,1
    80004c30:	20e4ac23          	sw	a4,536(s1)
    80004c34:	1ff7f793          	andi	a5,a5,511
    80004c38:	97a6                	add	a5,a5,s1
    80004c3a:	0187c783          	lbu	a5,24(a5)
    80004c3e:	faf40fa3          	sb	a5,-65(s0)
    if(copyout(pr->pagetable, addr + i, &ch, 1) == -1)
    80004c42:	4685                	li	a3,1
    80004c44:	fbf40613          	addi	a2,s0,-65
    80004c48:	85ce                	mv	a1,s3
    80004c4a:	048ab503          	ld	a0,72(s5)
    80004c4e:	ffffd097          	auipc	ra,0xffffd
    80004c52:	95e080e7          	jalr	-1698(ra) # 800015ac <copyout>
    80004c56:	f96507e3          	beq	a0,s6,80004be4 <piperead+0x72>
  for(i = 0; i < n; i++){  //DOC: piperead-copy
    80004c5a:	2905                	addiw	s2,s2,1
    80004c5c:	f92a04e3          	beq	s4,s2,80004be4 <piperead+0x72>
    if(pi->nread == pi->nwrite)
    80004c60:	2184a783          	lw	a5,536(s1)
    80004c64:	0985                	addi	s3,s3,1
    80004c66:	21c4a703          	lw	a4,540(s1)
    80004c6a:	fcf711e3          	bne	a4,a5,80004c2c <piperead+0xba>
    80004c6e:	bf9d                	j	80004be4 <piperead+0x72>

0000000080004c70 <exec>:

static int loadseg(pde_t *pgdir, uint64 addr, struct inode *ip, uint offset, uint sz);

int
exec(char *path, char **argv)
{
    80004c70:	de010113          	addi	sp,sp,-544
    80004c74:	20113c23          	sd	ra,536(sp)
    80004c78:	20813823          	sd	s0,528(sp)
    80004c7c:	20913423          	sd	s1,520(sp)
    80004c80:	21213023          	sd	s2,512(sp)
    80004c84:	ffce                	sd	s3,504(sp)
    80004c86:	fbd2                	sd	s4,496(sp)
    80004c88:	f7d6                	sd	s5,488(sp)
    80004c8a:	f3da                	sd	s6,480(sp)
    80004c8c:	efde                	sd	s7,472(sp)
    80004c8e:	ebe2                	sd	s8,464(sp)
    80004c90:	e7e6                	sd	s9,456(sp)
    80004c92:	e3ea                	sd	s10,448(sp)
    80004c94:	ff6e                	sd	s11,440(sp)
    80004c96:	1400                	addi	s0,sp,544
    80004c98:	892a                	mv	s2,a0
    80004c9a:	dea43823          	sd	a0,-528(s0)
    80004c9e:	deb43c23          	sd	a1,-520(s0)
  uint64 argc, sz, sp, ustack[MAXARG+1], stackbase;
  struct elfhdr elf;
  struct inode *ip;
  struct proghdr ph;
  pagetable_t pagetable = 0, oldpagetable;
  struct proc *p = myproc();
    80004ca2:	ffffd097          	auipc	ra,0xffffd
    80004ca6:	bfc080e7          	jalr	-1028(ra) # 8000189e <myproc>
    80004caa:	84aa                	mv	s1,a0

  begin_op(ROOTDEV);
    80004cac:	4501                	li	a0,0
    80004cae:	fffff097          	auipc	ra,0xfffff
    80004cb2:	2d2080e7          	jalr	722(ra) # 80003f80 <begin_op>

  if((ip = namei(path)) == 0){
    80004cb6:	854a                	mv	a0,s2
    80004cb8:	fffff097          	auipc	ra,0xfffff
    80004cbc:	fae080e7          	jalr	-82(ra) # 80003c66 <namei>
    80004cc0:	cd25                	beqz	a0,80004d38 <exec+0xc8>
    80004cc2:	892a                	mv	s2,a0
    end_op(ROOTDEV);
    return -1;
  }
  ilock(ip);
    80004cc4:	fffff097          	auipc	ra,0xfffff
    80004cc8:	80c080e7          	jalr	-2036(ra) # 800034d0 <ilock>

  // Check ELF header
  if(readi(ip, 0, (uint64)&elf, 0, sizeof(elf)) != sizeof(elf))
    80004ccc:	04000713          	li	a4,64
    80004cd0:	4681                	li	a3,0
    80004cd2:	e4840613          	addi	a2,s0,-440
    80004cd6:	4581                	li	a1,0
    80004cd8:	854a                	mv	a0,s2
    80004cda:	fffff097          	auipc	ra,0xfffff
    80004cde:	a88080e7          	jalr	-1400(ra) # 80003762 <readi>
    80004ce2:	04000793          	li	a5,64
    80004ce6:	00f51a63          	bne	a0,a5,80004cfa <exec+0x8a>
    goto bad;
  if(elf.magic != ELF_MAGIC)
    80004cea:	e4842703          	lw	a4,-440(s0)
    80004cee:	464c47b7          	lui	a5,0x464c4
    80004cf2:	57f78793          	addi	a5,a5,1407 # 464c457f <_entry-0x39b3ba81>
    80004cf6:	04f70863          	beq	a4,a5,80004d46 <exec+0xd6>

 bad:
  if(pagetable)
    proc_freepagetable(pagetable, sz);
  if(ip){
    iunlockput(ip);
    80004cfa:	854a                	mv	a0,s2
    80004cfc:	fffff097          	auipc	ra,0xfffff
    80004d00:	a14080e7          	jalr	-1516(ra) # 80003710 <iunlockput>
    end_op(ROOTDEV);
    80004d04:	4501                	li	a0,0
    80004d06:	fffff097          	auipc	ra,0xfffff
    80004d0a:	324080e7          	jalr	804(ra) # 8000402a <end_op>
  }
  return -1;
    80004d0e:	557d                	li	a0,-1
}
    80004d10:	21813083          	ld	ra,536(sp)
    80004d14:	21013403          	ld	s0,528(sp)
    80004d18:	20813483          	ld	s1,520(sp)
    80004d1c:	20013903          	ld	s2,512(sp)
    80004d20:	79fe                	ld	s3,504(sp)
    80004d22:	7a5e                	ld	s4,496(sp)
    80004d24:	7abe                	ld	s5,488(sp)
    80004d26:	7b1e                	ld	s6,480(sp)
    80004d28:	6bfe                	ld	s7,472(sp)
    80004d2a:	6c5e                	ld	s8,464(sp)
    80004d2c:	6cbe                	ld	s9,456(sp)
    80004d2e:	6d1e                	ld	s10,448(sp)
    80004d30:	7dfa                	ld	s11,440(sp)
    80004d32:	22010113          	addi	sp,sp,544
    80004d36:	8082                	ret
    end_op(ROOTDEV);
    80004d38:	4501                	li	a0,0
    80004d3a:	fffff097          	auipc	ra,0xfffff
    80004d3e:	2f0080e7          	jalr	752(ra) # 8000402a <end_op>
    return -1;
    80004d42:	557d                	li	a0,-1
    80004d44:	b7f1                	j	80004d10 <exec+0xa0>
  if((pagetable = proc_pagetable(p)) == 0)
    80004d46:	8526                	mv	a0,s1
    80004d48:	ffffd097          	auipc	ra,0xffffd
    80004d4c:	c1c080e7          	jalr	-996(ra) # 80001964 <proc_pagetable>
    80004d50:	e0a43423          	sd	a0,-504(s0)
    80004d54:	d15d                	beqz	a0,80004cfa <exec+0x8a>
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
    80004d56:	e6842983          	lw	s3,-408(s0)
    80004d5a:	e8045783          	lhu	a5,-384(s0)
    80004d5e:	cbed                	beqz	a5,80004e50 <exec+0x1e0>
  sz = 0;
    80004d60:	e0043023          	sd	zero,-512(s0)
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
    80004d64:	4b01                	li	s6,0
    if(ph.vaddr % PGSIZE != 0)
    80004d66:	6c05                	lui	s8,0x1
    80004d68:	fffc0793          	addi	a5,s8,-1 # fff <_entry-0x7ffff001>
    80004d6c:	def43423          	sd	a5,-536(s0)
  uint64 pa;

  if((va % PGSIZE) != 0)
    panic("loadseg: va must be page aligned");

  for(i = 0; i < sz; i += PGSIZE){
    80004d70:	6d05                	lui	s10,0x1
    80004d72:	a0a5                	j	80004dda <exec+0x16a>
    pa = walkaddr(pagetable, va + i);
    if(pa == 0)
      panic("loadseg: address should exist");
    80004d74:	00003517          	auipc	a0,0x3
    80004d78:	9dc50513          	addi	a0,a0,-1572 # 80007750 <userret+0x6c0>
    80004d7c:	ffffc097          	auipc	ra,0xffffc
    80004d80:	802080e7          	jalr	-2046(ra) # 8000057e <panic>
    if(sz - i < PGSIZE)
      n = sz - i;
    else
      n = PGSIZE;
    if(readi(ip, 0, (uint64)pa, offset+i, n) != n)
    80004d84:	8756                	mv	a4,s5
    80004d86:	009d86bb          	addw	a3,s11,s1
    80004d8a:	4581                	li	a1,0
    80004d8c:	854a                	mv	a0,s2
    80004d8e:	fffff097          	auipc	ra,0xfffff
    80004d92:	9d4080e7          	jalr	-1580(ra) # 80003762 <readi>
    80004d96:	2501                	sext.w	a0,a0
    80004d98:	10aa9563          	bne	s5,a0,80004ea2 <exec+0x232>
  for(i = 0; i < sz; i += PGSIZE){
    80004d9c:	009d04bb          	addw	s1,s10,s1
    80004da0:	77fd                	lui	a5,0xfffff
    80004da2:	01478a3b          	addw	s4,a5,s4
    80004da6:	0374f363          	bleu	s7,s1,80004dcc <exec+0x15c>
    pa = walkaddr(pagetable, va + i);
    80004daa:	02049593          	slli	a1,s1,0x20
    80004dae:	9181                	srli	a1,a1,0x20
    80004db0:	95e6                	add	a1,a1,s9
    80004db2:	e0843503          	ld	a0,-504(s0)
    80004db6:	ffffc097          	auipc	ra,0xffffc
    80004dba:	232080e7          	jalr	562(ra) # 80000fe8 <walkaddr>
    80004dbe:	862a                	mv	a2,a0
    if(pa == 0)
    80004dc0:	d955                	beqz	a0,80004d74 <exec+0x104>
      n = PGSIZE;
    80004dc2:	8ae2                	mv	s5,s8
    if(sz - i < PGSIZE)
    80004dc4:	fd8a70e3          	bleu	s8,s4,80004d84 <exec+0x114>
      n = sz - i;
    80004dc8:	8ad2                	mv	s5,s4
    80004dca:	bf6d                	j	80004d84 <exec+0x114>
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
    80004dcc:	2b05                	addiw	s6,s6,1
    80004dce:	0389899b          	addiw	s3,s3,56
    80004dd2:	e8045783          	lhu	a5,-384(s0)
    80004dd6:	06fb5f63          	ble	a5,s6,80004e54 <exec+0x1e4>
    if(readi(ip, 0, (uint64)&ph, off, sizeof(ph)) != sizeof(ph))
    80004dda:	2981                	sext.w	s3,s3
    80004ddc:	03800713          	li	a4,56
    80004de0:	86ce                	mv	a3,s3
    80004de2:	e1040613          	addi	a2,s0,-496
    80004de6:	4581                	li	a1,0
    80004de8:	854a                	mv	a0,s2
    80004dea:	fffff097          	auipc	ra,0xfffff
    80004dee:	978080e7          	jalr	-1672(ra) # 80003762 <readi>
    80004df2:	03800793          	li	a5,56
    80004df6:	0af51663          	bne	a0,a5,80004ea2 <exec+0x232>
    if(ph.type != ELF_PROG_LOAD)
    80004dfa:	e1042783          	lw	a5,-496(s0)
    80004dfe:	4705                	li	a4,1
    80004e00:	fce796e3          	bne	a5,a4,80004dcc <exec+0x15c>
    if(ph.memsz < ph.filesz)
    80004e04:	e3843603          	ld	a2,-456(s0)
    80004e08:	e3043783          	ld	a5,-464(s0)
    80004e0c:	08f66b63          	bltu	a2,a5,80004ea2 <exec+0x232>
    if(ph.vaddr + ph.memsz < ph.vaddr)
    80004e10:	e2043783          	ld	a5,-480(s0)
    80004e14:	963e                	add	a2,a2,a5
    80004e16:	08f66663          	bltu	a2,a5,80004ea2 <exec+0x232>
    if((sz = uvmalloc(pagetable, sz, ph.vaddr + ph.memsz)) == 0)
    80004e1a:	e0043583          	ld	a1,-512(s0)
    80004e1e:	e0843503          	ld	a0,-504(s0)
    80004e22:	ffffc097          	auipc	ra,0xffffc
    80004e26:	5b0080e7          	jalr	1456(ra) # 800013d2 <uvmalloc>
    80004e2a:	e0a43023          	sd	a0,-512(s0)
    80004e2e:	c935                	beqz	a0,80004ea2 <exec+0x232>
    if(ph.vaddr % PGSIZE != 0)
    80004e30:	e2043c83          	ld	s9,-480(s0)
    80004e34:	de843783          	ld	a5,-536(s0)
    80004e38:	00fcf7b3          	and	a5,s9,a5
    80004e3c:	e3bd                	bnez	a5,80004ea2 <exec+0x232>
    if(loadseg(pagetable, ph.vaddr, ip, ph.off, ph.filesz) < 0)
    80004e3e:	e1842d83          	lw	s11,-488(s0)
    80004e42:	e3042b83          	lw	s7,-464(s0)
  for(i = 0; i < sz; i += PGSIZE){
    80004e46:	f80b83e3          	beqz	s7,80004dcc <exec+0x15c>
    80004e4a:	8a5e                	mv	s4,s7
    80004e4c:	4481                	li	s1,0
    80004e4e:	bfb1                	j	80004daa <exec+0x13a>
  sz = 0;
    80004e50:	e0043023          	sd	zero,-512(s0)
  iunlockput(ip);
    80004e54:	854a                	mv	a0,s2
    80004e56:	fffff097          	auipc	ra,0xfffff
    80004e5a:	8ba080e7          	jalr	-1862(ra) # 80003710 <iunlockput>
  end_op(ROOTDEV);
    80004e5e:	4501                	li	a0,0
    80004e60:	fffff097          	auipc	ra,0xfffff
    80004e64:	1ca080e7          	jalr	458(ra) # 8000402a <end_op>
  p = myproc();
    80004e68:	ffffd097          	auipc	ra,0xffffd
    80004e6c:	a36080e7          	jalr	-1482(ra) # 8000189e <myproc>
    80004e70:	8b2a                	mv	s6,a0
  uint64 oldsz = p->sz;
    80004e72:	04053c83          	ld	s9,64(a0)
  sz = PGROUNDUP(sz);
    80004e76:	6585                	lui	a1,0x1
    80004e78:	15fd                	addi	a1,a1,-1
    80004e7a:	e0043783          	ld	a5,-512(s0)
    80004e7e:	00b78d33          	add	s10,a5,a1
    80004e82:	75fd                	lui	a1,0xfffff
    80004e84:	00bd75b3          	and	a1,s10,a1
  if((sz = uvmalloc(pagetable, sz, sz + 2*PGSIZE)) == 0)
    80004e88:	6609                	lui	a2,0x2
    80004e8a:	962e                	add	a2,a2,a1
    80004e8c:	e0843483          	ld	s1,-504(s0)
    80004e90:	8526                	mv	a0,s1
    80004e92:	ffffc097          	auipc	ra,0xffffc
    80004e96:	540080e7          	jalr	1344(ra) # 800013d2 <uvmalloc>
    80004e9a:	e0a43023          	sd	a0,-512(s0)
  ip = 0;
    80004e9e:	4901                	li	s2,0
  if((sz = uvmalloc(pagetable, sz, sz + 2*PGSIZE)) == 0)
    80004ea0:	ed09                	bnez	a0,80004eba <exec+0x24a>
    proc_freepagetable(pagetable, sz);
    80004ea2:	e0043583          	ld	a1,-512(s0)
    80004ea6:	e0843503          	ld	a0,-504(s0)
    80004eaa:	ffffd097          	auipc	ra,0xffffd
    80004eae:	bba080e7          	jalr	-1094(ra) # 80001a64 <proc_freepagetable>
  if(ip){
    80004eb2:	e40914e3          	bnez	s2,80004cfa <exec+0x8a>
  return -1;
    80004eb6:	557d                	li	a0,-1
    80004eb8:	bda1                	j	80004d10 <exec+0xa0>
  uvmclear(pagetable, sz-2*PGSIZE);
    80004eba:	75f9                	lui	a1,0xffffe
    80004ebc:	892a                	mv	s2,a0
    80004ebe:	95aa                	add	a1,a1,a0
    80004ec0:	8526                	mv	a0,s1
    80004ec2:	ffffc097          	auipc	ra,0xffffc
    80004ec6:	6b8080e7          	jalr	1720(ra) # 8000157a <uvmclear>
  stackbase = sp - PGSIZE;
    80004eca:	7afd                	lui	s5,0xfffff
    80004ecc:	9aca                	add	s5,s5,s2
  for(argc = 0; argv[argc]; argc++) {
    80004ece:	df843783          	ld	a5,-520(s0)
    80004ed2:	6388                	ld	a0,0(a5)
    80004ed4:	c52d                	beqz	a0,80004f3e <exec+0x2ce>
    80004ed6:	e8840993          	addi	s3,s0,-376
    80004eda:	f8840b93          	addi	s7,s0,-120
    80004ede:	4481                	li	s1,0
    sp -= strlen(argv[argc]) + 1;
    80004ee0:	ffffc097          	auipc	ra,0xffffc
    80004ee4:	e90080e7          	jalr	-368(ra) # 80000d70 <strlen>
    80004ee8:	2505                	addiw	a0,a0,1
    80004eea:	40a90933          	sub	s2,s2,a0
    sp -= sp % 16; // riscv sp must be 16-byte aligned
    80004eee:	ff097913          	andi	s2,s2,-16
    if(sp < stackbase)
    80004ef2:	0f596f63          	bltu	s2,s5,80004ff0 <exec+0x380>
    if(copyout(pagetable, sp, argv[argc], strlen(argv[argc]) + 1) < 0)
    80004ef6:	df843c03          	ld	s8,-520(s0)
    80004efa:	000c3a03          	ld	s4,0(s8)
    80004efe:	8552                	mv	a0,s4
    80004f00:	ffffc097          	auipc	ra,0xffffc
    80004f04:	e70080e7          	jalr	-400(ra) # 80000d70 <strlen>
    80004f08:	0015069b          	addiw	a3,a0,1
    80004f0c:	8652                	mv	a2,s4
    80004f0e:	85ca                	mv	a1,s2
    80004f10:	e0843503          	ld	a0,-504(s0)
    80004f14:	ffffc097          	auipc	ra,0xffffc
    80004f18:	698080e7          	jalr	1688(ra) # 800015ac <copyout>
    80004f1c:	0c054c63          	bltz	a0,80004ff4 <exec+0x384>
    ustack[argc] = sp;
    80004f20:	0129b023          	sd	s2,0(s3)
  for(argc = 0; argv[argc]; argc++) {
    80004f24:	0485                	addi	s1,s1,1
    80004f26:	008c0793          	addi	a5,s8,8
    80004f2a:	def43c23          	sd	a5,-520(s0)
    80004f2e:	008c3503          	ld	a0,8(s8)
    80004f32:	c909                	beqz	a0,80004f44 <exec+0x2d4>
    if(argc >= MAXARG)
    80004f34:	09a1                	addi	s3,s3,8
    80004f36:	fb7995e3          	bne	s3,s7,80004ee0 <exec+0x270>
  ip = 0;
    80004f3a:	4901                	li	s2,0
    80004f3c:	b79d                	j	80004ea2 <exec+0x232>
  sp = sz;
    80004f3e:	e0043903          	ld	s2,-512(s0)
  for(argc = 0; argv[argc]; argc++) {
    80004f42:	4481                	li	s1,0
  ustack[argc] = 0;
    80004f44:	00349793          	slli	a5,s1,0x3
    80004f48:	f9040713          	addi	a4,s0,-112
    80004f4c:	97ba                	add	a5,a5,a4
    80004f4e:	ee07bc23          	sd	zero,-264(a5) # ffffffffffffeef8 <ticks+0xffffffff7ffd5ed0>
  sp -= (argc+1) * sizeof(uint64);
    80004f52:	00148693          	addi	a3,s1,1
    80004f56:	068e                	slli	a3,a3,0x3
    80004f58:	40d90933          	sub	s2,s2,a3
  sp -= sp % 16;
    80004f5c:	ff097993          	andi	s3,s2,-16
  ip = 0;
    80004f60:	4901                	li	s2,0
  if(sp < stackbase)
    80004f62:	f559e0e3          	bltu	s3,s5,80004ea2 <exec+0x232>
  if(copyout(pagetable, sp, (char *)ustack, (argc+1)*sizeof(uint64)) < 0)
    80004f66:	e8840613          	addi	a2,s0,-376
    80004f6a:	85ce                	mv	a1,s3
    80004f6c:	e0843503          	ld	a0,-504(s0)
    80004f70:	ffffc097          	auipc	ra,0xffffc
    80004f74:	63c080e7          	jalr	1596(ra) # 800015ac <copyout>
    80004f78:	08054063          	bltz	a0,80004ff8 <exec+0x388>
  p->tf->a1 = sp;
    80004f7c:	050b3783          	ld	a5,80(s6)
    80004f80:	0737bc23          	sd	s3,120(a5)
  for(last=s=path; *s; s++)
    80004f84:	df043783          	ld	a5,-528(s0)
    80004f88:	0007c703          	lbu	a4,0(a5)
    80004f8c:	cf11                	beqz	a4,80004fa8 <exec+0x338>
    80004f8e:	0785                	addi	a5,a5,1
    if(*s == '/')
    80004f90:	02f00693          	li	a3,47
    80004f94:	a029                	j	80004f9e <exec+0x32e>
  for(last=s=path; *s; s++)
    80004f96:	0785                	addi	a5,a5,1
    80004f98:	fff7c703          	lbu	a4,-1(a5)
    80004f9c:	c711                	beqz	a4,80004fa8 <exec+0x338>
    if(*s == '/')
    80004f9e:	fed71ce3          	bne	a4,a3,80004f96 <exec+0x326>
      last = s+1;
    80004fa2:	def43823          	sd	a5,-528(s0)
    80004fa6:	bfc5                	j	80004f96 <exec+0x326>
  safestrcpy(p->name, last, sizeof(p->name));
    80004fa8:	4641                	li	a2,16
    80004faa:	df043583          	ld	a1,-528(s0)
    80004fae:	150b0513          	addi	a0,s6,336
    80004fb2:	ffffc097          	auipc	ra,0xffffc
    80004fb6:	d8c080e7          	jalr	-628(ra) # 80000d3e <safestrcpy>
  oldpagetable = p->pagetable;
    80004fba:	048b3503          	ld	a0,72(s6)
  p->pagetable = pagetable;
    80004fbe:	e0843783          	ld	a5,-504(s0)
    80004fc2:	04fb3423          	sd	a5,72(s6)
  p->sz = sz;
    80004fc6:	e0043783          	ld	a5,-512(s0)
    80004fca:	04fb3023          	sd	a5,64(s6)
  p->tf->epc = elf.entry;  // initial program counter = main
    80004fce:	050b3783          	ld	a5,80(s6)
    80004fd2:	e6043703          	ld	a4,-416(s0)
    80004fd6:	ef98                	sd	a4,24(a5)
  p->tf->sp = sp; // initial stack pointer
    80004fd8:	050b3783          	ld	a5,80(s6)
    80004fdc:	0337b823          	sd	s3,48(a5)
  proc_freepagetable(oldpagetable, oldsz);
    80004fe0:	85e6                	mv	a1,s9
    80004fe2:	ffffd097          	auipc	ra,0xffffd
    80004fe6:	a82080e7          	jalr	-1406(ra) # 80001a64 <proc_freepagetable>
  return argc; // this ends up in a0, the first argument to main(argc, argv)
    80004fea:	0004851b          	sext.w	a0,s1
    80004fee:	b30d                	j	80004d10 <exec+0xa0>
  ip = 0;
    80004ff0:	4901                	li	s2,0
    80004ff2:	bd45                	j	80004ea2 <exec+0x232>
    80004ff4:	4901                	li	s2,0
    80004ff6:	b575                	j	80004ea2 <exec+0x232>
    80004ff8:	4901                	li	s2,0
    80004ffa:	b565                	j	80004ea2 <exec+0x232>

0000000080004ffc <argfd>:

// Fetch the nth word-sized system call argument as a file descriptor
// and return both the descriptor and the corresponding struct file.
static int
argfd(int n, int *pfd, struct file **pf)
{
    80004ffc:	7179                	addi	sp,sp,-48
    80004ffe:	f406                	sd	ra,40(sp)
    80005000:	f022                	sd	s0,32(sp)
    80005002:	ec26                	sd	s1,24(sp)
    80005004:	e84a                	sd	s2,16(sp)
    80005006:	1800                	addi	s0,sp,48
    80005008:	892e                	mv	s2,a1
    8000500a:	84b2                	mv	s1,a2
  int fd;
  struct file *f;

  if(argint(n, &fd) < 0)
    8000500c:	fdc40593          	addi	a1,s0,-36
    80005010:	ffffe097          	auipc	ra,0xffffe
    80005014:	910080e7          	jalr	-1776(ra) # 80002920 <argint>
    80005018:	04054063          	bltz	a0,80005058 <argfd+0x5c>
    return -1;
  if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0)
    8000501c:	fdc42703          	lw	a4,-36(s0)
    80005020:	47bd                	li	a5,15
    80005022:	02e7ed63          	bltu	a5,a4,8000505c <argfd+0x60>
    80005026:	ffffd097          	auipc	ra,0xffffd
    8000502a:	878080e7          	jalr	-1928(ra) # 8000189e <myproc>
    8000502e:	fdc42703          	lw	a4,-36(s0)
    80005032:	01870793          	addi	a5,a4,24
    80005036:	078e                	slli	a5,a5,0x3
    80005038:	953e                	add	a0,a0,a5
    8000503a:	651c                	ld	a5,8(a0)
    8000503c:	c395                	beqz	a5,80005060 <argfd+0x64>
    return -1;
  if(pfd)
    8000503e:	00090463          	beqz	s2,80005046 <argfd+0x4a>
    *pfd = fd;
    80005042:	00e92023          	sw	a4,0(s2)
  if(pf)
    *pf = f;
  return 0;
    80005046:	4501                	li	a0,0
  if(pf)
    80005048:	c091                	beqz	s1,8000504c <argfd+0x50>
    *pf = f;
    8000504a:	e09c                	sd	a5,0(s1)
}
    8000504c:	70a2                	ld	ra,40(sp)
    8000504e:	7402                	ld	s0,32(sp)
    80005050:	64e2                	ld	s1,24(sp)
    80005052:	6942                	ld	s2,16(sp)
    80005054:	6145                	addi	sp,sp,48
    80005056:	8082                	ret
    return -1;
    80005058:	557d                	li	a0,-1
    8000505a:	bfcd                	j	8000504c <argfd+0x50>
    return -1;
    8000505c:	557d                	li	a0,-1
    8000505e:	b7fd                	j	8000504c <argfd+0x50>
    80005060:	557d                	li	a0,-1
    80005062:	b7ed                	j	8000504c <argfd+0x50>

0000000080005064 <fdalloc>:

// Allocate a file descriptor for the given file.
// Takes over file reference from caller on success.
static int
fdalloc(struct file *f)
{
    80005064:	1101                	addi	sp,sp,-32
    80005066:	ec06                	sd	ra,24(sp)
    80005068:	e822                	sd	s0,16(sp)
    8000506a:	e426                	sd	s1,8(sp)
    8000506c:	1000                	addi	s0,sp,32
    8000506e:	84aa                	mv	s1,a0
  int fd;
  struct proc *p = myproc();
    80005070:	ffffd097          	auipc	ra,0xffffd
    80005074:	82e080e7          	jalr	-2002(ra) # 8000189e <myproc>

  for(fd = 0; fd < NOFILE; fd++){
    if(p->ofile[fd] == 0){
    80005078:	657c                	ld	a5,200(a0)
    8000507a:	c395                	beqz	a5,8000509e <fdalloc+0x3a>
    8000507c:	0d050713          	addi	a4,a0,208
  for(fd = 0; fd < NOFILE; fd++){
    80005080:	4785                	li	a5,1
    80005082:	4641                	li	a2,16
    if(p->ofile[fd] == 0){
    80005084:	6314                	ld	a3,0(a4)
    80005086:	ce89                	beqz	a3,800050a0 <fdalloc+0x3c>
  for(fd = 0; fd < NOFILE; fd++){
    80005088:	2785                	addiw	a5,a5,1
    8000508a:	0721                	addi	a4,a4,8
    8000508c:	fec79ce3          	bne	a5,a2,80005084 <fdalloc+0x20>
      p->ofile[fd] = f;
      return fd;
    }
  }
  return -1;
    80005090:	57fd                	li	a5,-1
}
    80005092:	853e                	mv	a0,a5
    80005094:	60e2                	ld	ra,24(sp)
    80005096:	6442                	ld	s0,16(sp)
    80005098:	64a2                	ld	s1,8(sp)
    8000509a:	6105                	addi	sp,sp,32
    8000509c:	8082                	ret
  for(fd = 0; fd < NOFILE; fd++){
    8000509e:	4781                	li	a5,0
      p->ofile[fd] = f;
    800050a0:	01878713          	addi	a4,a5,24
    800050a4:	070e                	slli	a4,a4,0x3
    800050a6:	953a                	add	a0,a0,a4
    800050a8:	e504                	sd	s1,8(a0)
      return fd;
    800050aa:	b7e5                	j	80005092 <fdalloc+0x2e>

00000000800050ac <create>:
  return -1;
}

static struct inode*
create(char *path, short type, short major, short minor)
{
    800050ac:	715d                	addi	sp,sp,-80
    800050ae:	e486                	sd	ra,72(sp)
    800050b0:	e0a2                	sd	s0,64(sp)
    800050b2:	fc26                	sd	s1,56(sp)
    800050b4:	f84a                	sd	s2,48(sp)
    800050b6:	f44e                	sd	s3,40(sp)
    800050b8:	f052                	sd	s4,32(sp)
    800050ba:	ec56                	sd	s5,24(sp)
    800050bc:	0880                	addi	s0,sp,80
    800050be:	89ae                	mv	s3,a1
    800050c0:	8ab2                	mv	s5,a2
    800050c2:	8a36                	mv	s4,a3
  struct inode *ip, *dp;
  char name[DIRSIZ];

  if((dp = nameiparent(path, name)) == 0)
    800050c4:	fb040593          	addi	a1,s0,-80
    800050c8:	fffff097          	auipc	ra,0xfffff
    800050cc:	bbc080e7          	jalr	-1092(ra) # 80003c84 <nameiparent>
    800050d0:	892a                	mv	s2,a0
    800050d2:	12050f63          	beqz	a0,80005210 <create+0x164>
    return 0;
  ilock(dp);
    800050d6:	ffffe097          	auipc	ra,0xffffe
    800050da:	3fa080e7          	jalr	1018(ra) # 800034d0 <ilock>

  if((ip = dirlookup(dp, name, 0)) != 0){
    800050de:	4601                	li	a2,0
    800050e0:	fb040593          	addi	a1,s0,-80
    800050e4:	854a                	mv	a0,s2
    800050e6:	fffff097          	auipc	ra,0xfffff
    800050ea:	8a6080e7          	jalr	-1882(ra) # 8000398c <dirlookup>
    800050ee:	84aa                	mv	s1,a0
    800050f0:	c921                	beqz	a0,80005140 <create+0x94>
    iunlockput(dp);
    800050f2:	854a                	mv	a0,s2
    800050f4:	ffffe097          	auipc	ra,0xffffe
    800050f8:	61c080e7          	jalr	1564(ra) # 80003710 <iunlockput>
    ilock(ip);
    800050fc:	8526                	mv	a0,s1
    800050fe:	ffffe097          	auipc	ra,0xffffe
    80005102:	3d2080e7          	jalr	978(ra) # 800034d0 <ilock>
    if(type == T_FILE && (ip->type == T_FILE || ip->type == T_DEVICE))
    80005106:	2981                	sext.w	s3,s3
    80005108:	4789                	li	a5,2
    8000510a:	02f99463          	bne	s3,a5,80005132 <create+0x86>
    8000510e:	0444d783          	lhu	a5,68(s1)
    80005112:	37f9                	addiw	a5,a5,-2
    80005114:	17c2                	slli	a5,a5,0x30
    80005116:	93c1                	srli	a5,a5,0x30
    80005118:	4705                	li	a4,1
    8000511a:	00f76c63          	bltu	a4,a5,80005132 <create+0x86>
    panic("create: dirlink");

  iunlockput(dp);

  return ip;
}
    8000511e:	8526                	mv	a0,s1
    80005120:	60a6                	ld	ra,72(sp)
    80005122:	6406                	ld	s0,64(sp)
    80005124:	74e2                	ld	s1,56(sp)
    80005126:	7942                	ld	s2,48(sp)
    80005128:	79a2                	ld	s3,40(sp)
    8000512a:	7a02                	ld	s4,32(sp)
    8000512c:	6ae2                	ld	s5,24(sp)
    8000512e:	6161                	addi	sp,sp,80
    80005130:	8082                	ret
    iunlockput(ip);
    80005132:	8526                	mv	a0,s1
    80005134:	ffffe097          	auipc	ra,0xffffe
    80005138:	5dc080e7          	jalr	1500(ra) # 80003710 <iunlockput>
    return 0;
    8000513c:	4481                	li	s1,0
    8000513e:	b7c5                	j	8000511e <create+0x72>
  if((ip = ialloc(dp->dev, type)) == 0)
    80005140:	85ce                	mv	a1,s3
    80005142:	00092503          	lw	a0,0(s2)
    80005146:	ffffe097          	auipc	ra,0xffffe
    8000514a:	1ee080e7          	jalr	494(ra) # 80003334 <ialloc>
    8000514e:	84aa                	mv	s1,a0
    80005150:	c529                	beqz	a0,8000519a <create+0xee>
  ilock(ip);
    80005152:	ffffe097          	auipc	ra,0xffffe
    80005156:	37e080e7          	jalr	894(ra) # 800034d0 <ilock>
  ip->major = major;
    8000515a:	05549323          	sh	s5,70(s1)
  ip->minor = minor;
    8000515e:	05449423          	sh	s4,72(s1)
  ip->nlink = 1;
    80005162:	4785                	li	a5,1
    80005164:	04f49523          	sh	a5,74(s1)
  iupdate(ip);
    80005168:	8526                	mv	a0,s1
    8000516a:	ffffe097          	auipc	ra,0xffffe
    8000516e:	29a080e7          	jalr	666(ra) # 80003404 <iupdate>
  if(type == T_DIR){  // Create . and .. entries.
    80005172:	2981                	sext.w	s3,s3
    80005174:	4785                	li	a5,1
    80005176:	02f98a63          	beq	s3,a5,800051aa <create+0xfe>
  if(dirlink(dp, name, ip->inum) < 0)
    8000517a:	40d0                	lw	a2,4(s1)
    8000517c:	fb040593          	addi	a1,s0,-80
    80005180:	854a                	mv	a0,s2
    80005182:	fffff097          	auipc	ra,0xfffff
    80005186:	a22080e7          	jalr	-1502(ra) # 80003ba4 <dirlink>
    8000518a:	06054b63          	bltz	a0,80005200 <create+0x154>
  iunlockput(dp);
    8000518e:	854a                	mv	a0,s2
    80005190:	ffffe097          	auipc	ra,0xffffe
    80005194:	580080e7          	jalr	1408(ra) # 80003710 <iunlockput>
  return ip;
    80005198:	b759                	j	8000511e <create+0x72>
    panic("create: ialloc");
    8000519a:	00002517          	auipc	a0,0x2
    8000519e:	5d650513          	addi	a0,a0,1494 # 80007770 <userret+0x6e0>
    800051a2:	ffffb097          	auipc	ra,0xffffb
    800051a6:	3dc080e7          	jalr	988(ra) # 8000057e <panic>
    dp->nlink++;  // for ".."
    800051aa:	04a95783          	lhu	a5,74(s2)
    800051ae:	2785                	addiw	a5,a5,1
    800051b0:	04f91523          	sh	a5,74(s2)
    iupdate(dp);
    800051b4:	854a                	mv	a0,s2
    800051b6:	ffffe097          	auipc	ra,0xffffe
    800051ba:	24e080e7          	jalr	590(ra) # 80003404 <iupdate>
    if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0)
    800051be:	40d0                	lw	a2,4(s1)
    800051c0:	00002597          	auipc	a1,0x2
    800051c4:	5c058593          	addi	a1,a1,1472 # 80007780 <userret+0x6f0>
    800051c8:	8526                	mv	a0,s1
    800051ca:	fffff097          	auipc	ra,0xfffff
    800051ce:	9da080e7          	jalr	-1574(ra) # 80003ba4 <dirlink>
    800051d2:	00054f63          	bltz	a0,800051f0 <create+0x144>
    800051d6:	00492603          	lw	a2,4(s2)
    800051da:	00002597          	auipc	a1,0x2
    800051de:	5ae58593          	addi	a1,a1,1454 # 80007788 <userret+0x6f8>
    800051e2:	8526                	mv	a0,s1
    800051e4:	fffff097          	auipc	ra,0xfffff
    800051e8:	9c0080e7          	jalr	-1600(ra) # 80003ba4 <dirlink>
    800051ec:	f80557e3          	bgez	a0,8000517a <create+0xce>
      panic("create dots");
    800051f0:	00002517          	auipc	a0,0x2
    800051f4:	5a050513          	addi	a0,a0,1440 # 80007790 <userret+0x700>
    800051f8:	ffffb097          	auipc	ra,0xffffb
    800051fc:	386080e7          	jalr	902(ra) # 8000057e <panic>
    panic("create: dirlink");
    80005200:	00002517          	auipc	a0,0x2
    80005204:	5a050513          	addi	a0,a0,1440 # 800077a0 <userret+0x710>
    80005208:	ffffb097          	auipc	ra,0xffffb
    8000520c:	376080e7          	jalr	886(ra) # 8000057e <panic>
    return 0;
    80005210:	84aa                	mv	s1,a0
    80005212:	b731                	j	8000511e <create+0x72>

0000000080005214 <sys_dup>:
{
    80005214:	7179                	addi	sp,sp,-48
    80005216:	f406                	sd	ra,40(sp)
    80005218:	f022                	sd	s0,32(sp)
    8000521a:	ec26                	sd	s1,24(sp)
    8000521c:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0)
    8000521e:	fd840613          	addi	a2,s0,-40
    80005222:	4581                	li	a1,0
    80005224:	4501                	li	a0,0
    80005226:	00000097          	auipc	ra,0x0
    8000522a:	dd6080e7          	jalr	-554(ra) # 80004ffc <argfd>
    return -1;
    8000522e:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0)
    80005230:	02054363          	bltz	a0,80005256 <sys_dup+0x42>
  if((fd=fdalloc(f)) < 0)
    80005234:	fd843503          	ld	a0,-40(s0)
    80005238:	00000097          	auipc	ra,0x0
    8000523c:	e2c080e7          	jalr	-468(ra) # 80005064 <fdalloc>
    80005240:	84aa                	mv	s1,a0
    return -1;
    80005242:	57fd                	li	a5,-1
  if((fd=fdalloc(f)) < 0)
    80005244:	00054963          	bltz	a0,80005256 <sys_dup+0x42>
  filedup(f);
    80005248:	fd843503          	ld	a0,-40(s0)
    8000524c:	fffff097          	auipc	ra,0xfffff
    80005250:	33c080e7          	jalr	828(ra) # 80004588 <filedup>
  return fd;
    80005254:	87a6                	mv	a5,s1
}
    80005256:	853e                	mv	a0,a5
    80005258:	70a2                	ld	ra,40(sp)
    8000525a:	7402                	ld	s0,32(sp)
    8000525c:	64e2                	ld	s1,24(sp)
    8000525e:	6145                	addi	sp,sp,48
    80005260:	8082                	ret

0000000080005262 <sys_read>:
{
    80005262:	7179                	addi	sp,sp,-48
    80005264:	f406                	sd	ra,40(sp)
    80005266:	f022                	sd	s0,32(sp)
    80005268:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    8000526a:	fe840613          	addi	a2,s0,-24
    8000526e:	4581                	li	a1,0
    80005270:	4501                	li	a0,0
    80005272:	00000097          	auipc	ra,0x0
    80005276:	d8a080e7          	jalr	-630(ra) # 80004ffc <argfd>
    return -1;
    8000527a:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    8000527c:	04054163          	bltz	a0,800052be <sys_read+0x5c>
    80005280:	fe440593          	addi	a1,s0,-28
    80005284:	4509                	li	a0,2
    80005286:	ffffd097          	auipc	ra,0xffffd
    8000528a:	69a080e7          	jalr	1690(ra) # 80002920 <argint>
    return -1;
    8000528e:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005290:	02054763          	bltz	a0,800052be <sys_read+0x5c>
    80005294:	fd840593          	addi	a1,s0,-40
    80005298:	4505                	li	a0,1
    8000529a:	ffffd097          	auipc	ra,0xffffd
    8000529e:	6a8080e7          	jalr	1704(ra) # 80002942 <argaddr>
    return -1;
    800052a2:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800052a4:	00054d63          	bltz	a0,800052be <sys_read+0x5c>
  return fileread(f, p, n);
    800052a8:	fe442603          	lw	a2,-28(s0)
    800052ac:	fd843583          	ld	a1,-40(s0)
    800052b0:	fe843503          	ld	a0,-24(s0)
    800052b4:	fffff097          	auipc	ra,0xfffff
    800052b8:	468080e7          	jalr	1128(ra) # 8000471c <fileread>
    800052bc:	87aa                	mv	a5,a0
}
    800052be:	853e                	mv	a0,a5
    800052c0:	70a2                	ld	ra,40(sp)
    800052c2:	7402                	ld	s0,32(sp)
    800052c4:	6145                	addi	sp,sp,48
    800052c6:	8082                	ret

00000000800052c8 <sys_write>:
{
    800052c8:	7179                	addi	sp,sp,-48
    800052ca:	f406                	sd	ra,40(sp)
    800052cc:	f022                	sd	s0,32(sp)
    800052ce:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800052d0:	fe840613          	addi	a2,s0,-24
    800052d4:	4581                	li	a1,0
    800052d6:	4501                	li	a0,0
    800052d8:	00000097          	auipc	ra,0x0
    800052dc:	d24080e7          	jalr	-732(ra) # 80004ffc <argfd>
    return -1;
    800052e0:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800052e2:	04054163          	bltz	a0,80005324 <sys_write+0x5c>
    800052e6:	fe440593          	addi	a1,s0,-28
    800052ea:	4509                	li	a0,2
    800052ec:	ffffd097          	auipc	ra,0xffffd
    800052f0:	634080e7          	jalr	1588(ra) # 80002920 <argint>
    return -1;
    800052f4:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800052f6:	02054763          	bltz	a0,80005324 <sys_write+0x5c>
    800052fa:	fd840593          	addi	a1,s0,-40
    800052fe:	4505                	li	a0,1
    80005300:	ffffd097          	auipc	ra,0xffffd
    80005304:	642080e7          	jalr	1602(ra) # 80002942 <argaddr>
    return -1;
    80005308:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    8000530a:	00054d63          	bltz	a0,80005324 <sys_write+0x5c>
  return filewrite(f, p, n);
    8000530e:	fe442603          	lw	a2,-28(s0)
    80005312:	fd843583          	ld	a1,-40(s0)
    80005316:	fe843503          	ld	a0,-24(s0)
    8000531a:	fffff097          	auipc	ra,0xfffff
    8000531e:	4b0080e7          	jalr	1200(ra) # 800047ca <filewrite>
    80005322:	87aa                	mv	a5,a0
}
    80005324:	853e                	mv	a0,a5
    80005326:	70a2                	ld	ra,40(sp)
    80005328:	7402                	ld	s0,32(sp)
    8000532a:	6145                	addi	sp,sp,48
    8000532c:	8082                	ret

000000008000532e <sys_close>:
{
    8000532e:	1101                	addi	sp,sp,-32
    80005330:	ec06                	sd	ra,24(sp)
    80005332:	e822                	sd	s0,16(sp)
    80005334:	1000                	addi	s0,sp,32
  if(argfd(0, &fd, &f) < 0)
    80005336:	fe040613          	addi	a2,s0,-32
    8000533a:	fec40593          	addi	a1,s0,-20
    8000533e:	4501                	li	a0,0
    80005340:	00000097          	auipc	ra,0x0
    80005344:	cbc080e7          	jalr	-836(ra) # 80004ffc <argfd>
    return -1;
    80005348:	57fd                	li	a5,-1
  if(argfd(0, &fd, &f) < 0)
    8000534a:	02054463          	bltz	a0,80005372 <sys_close+0x44>
  myproc()->ofile[fd] = 0;
    8000534e:	ffffc097          	auipc	ra,0xffffc
    80005352:	550080e7          	jalr	1360(ra) # 8000189e <myproc>
    80005356:	fec42783          	lw	a5,-20(s0)
    8000535a:	07e1                	addi	a5,a5,24
    8000535c:	078e                	slli	a5,a5,0x3
    8000535e:	953e                	add	a0,a0,a5
    80005360:	00053423          	sd	zero,8(a0)
  fileclose(f);
    80005364:	fe043503          	ld	a0,-32(s0)
    80005368:	fffff097          	auipc	ra,0xfffff
    8000536c:	272080e7          	jalr	626(ra) # 800045da <fileclose>
  return 0;
    80005370:	4781                	li	a5,0
}
    80005372:	853e                	mv	a0,a5
    80005374:	60e2                	ld	ra,24(sp)
    80005376:	6442                	ld	s0,16(sp)
    80005378:	6105                	addi	sp,sp,32
    8000537a:	8082                	ret

000000008000537c <sys_fstat>:
{
    8000537c:	1101                	addi	sp,sp,-32
    8000537e:	ec06                	sd	ra,24(sp)
    80005380:	e822                	sd	s0,16(sp)
    80005382:	1000                	addi	s0,sp,32
  if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
    80005384:	fe840613          	addi	a2,s0,-24
    80005388:	4581                	li	a1,0
    8000538a:	4501                	li	a0,0
    8000538c:	00000097          	auipc	ra,0x0
    80005390:	c70080e7          	jalr	-912(ra) # 80004ffc <argfd>
    return -1;
    80005394:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
    80005396:	02054563          	bltz	a0,800053c0 <sys_fstat+0x44>
    8000539a:	fe040593          	addi	a1,s0,-32
    8000539e:	4505                	li	a0,1
    800053a0:	ffffd097          	auipc	ra,0xffffd
    800053a4:	5a2080e7          	jalr	1442(ra) # 80002942 <argaddr>
    return -1;
    800053a8:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
    800053aa:	00054b63          	bltz	a0,800053c0 <sys_fstat+0x44>
  return filestat(f, st);
    800053ae:	fe043583          	ld	a1,-32(s0)
    800053b2:	fe843503          	ld	a0,-24(s0)
    800053b6:	fffff097          	auipc	ra,0xfffff
    800053ba:	2f4080e7          	jalr	756(ra) # 800046aa <filestat>
    800053be:	87aa                	mv	a5,a0
}
    800053c0:	853e                	mv	a0,a5
    800053c2:	60e2                	ld	ra,24(sp)
    800053c4:	6442                	ld	s0,16(sp)
    800053c6:	6105                	addi	sp,sp,32
    800053c8:	8082                	ret

00000000800053ca <sys_link>:
{
    800053ca:	7169                	addi	sp,sp,-304
    800053cc:	f606                	sd	ra,296(sp)
    800053ce:	f222                	sd	s0,288(sp)
    800053d0:	ee26                	sd	s1,280(sp)
    800053d2:	ea4a                	sd	s2,272(sp)
    800053d4:	1a00                	addi	s0,sp,304
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    800053d6:	08000613          	li	a2,128
    800053da:	ed040593          	addi	a1,s0,-304
    800053de:	4501                	li	a0,0
    800053e0:	ffffd097          	auipc	ra,0xffffd
    800053e4:	584080e7          	jalr	1412(ra) # 80002964 <argstr>
    return -1;
    800053e8:	57fd                	li	a5,-1
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    800053ea:	12054363          	bltz	a0,80005510 <sys_link+0x146>
    800053ee:	08000613          	li	a2,128
    800053f2:	f5040593          	addi	a1,s0,-176
    800053f6:	4505                	li	a0,1
    800053f8:	ffffd097          	auipc	ra,0xffffd
    800053fc:	56c080e7          	jalr	1388(ra) # 80002964 <argstr>
    return -1;
    80005400:	57fd                	li	a5,-1
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    80005402:	10054763          	bltz	a0,80005510 <sys_link+0x146>
  begin_op(ROOTDEV);
    80005406:	4501                	li	a0,0
    80005408:	fffff097          	auipc	ra,0xfffff
    8000540c:	b78080e7          	jalr	-1160(ra) # 80003f80 <begin_op>
  if((ip = namei(old)) == 0){
    80005410:	ed040513          	addi	a0,s0,-304
    80005414:	fffff097          	auipc	ra,0xfffff
    80005418:	852080e7          	jalr	-1966(ra) # 80003c66 <namei>
    8000541c:	84aa                	mv	s1,a0
    8000541e:	c559                	beqz	a0,800054ac <sys_link+0xe2>
  ilock(ip);
    80005420:	ffffe097          	auipc	ra,0xffffe
    80005424:	0b0080e7          	jalr	176(ra) # 800034d0 <ilock>
  if(ip->type == T_DIR){
    80005428:	04449703          	lh	a4,68(s1)
    8000542c:	4785                	li	a5,1
    8000542e:	08f70663          	beq	a4,a5,800054ba <sys_link+0xf0>
  ip->nlink++;
    80005432:	04a4d783          	lhu	a5,74(s1)
    80005436:	2785                	addiw	a5,a5,1
    80005438:	04f49523          	sh	a5,74(s1)
  iupdate(ip);
    8000543c:	8526                	mv	a0,s1
    8000543e:	ffffe097          	auipc	ra,0xffffe
    80005442:	fc6080e7          	jalr	-58(ra) # 80003404 <iupdate>
  iunlock(ip);
    80005446:	8526                	mv	a0,s1
    80005448:	ffffe097          	auipc	ra,0xffffe
    8000544c:	14c080e7          	jalr	332(ra) # 80003594 <iunlock>
  if((dp = nameiparent(new, name)) == 0)
    80005450:	fd040593          	addi	a1,s0,-48
    80005454:	f5040513          	addi	a0,s0,-176
    80005458:	fffff097          	auipc	ra,0xfffff
    8000545c:	82c080e7          	jalr	-2004(ra) # 80003c84 <nameiparent>
    80005460:	892a                	mv	s2,a0
    80005462:	cd2d                	beqz	a0,800054dc <sys_link+0x112>
  ilock(dp);
    80005464:	ffffe097          	auipc	ra,0xffffe
    80005468:	06c080e7          	jalr	108(ra) # 800034d0 <ilock>
  if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){
    8000546c:	00092703          	lw	a4,0(s2)
    80005470:	409c                	lw	a5,0(s1)
    80005472:	06f71063          	bne	a4,a5,800054d2 <sys_link+0x108>
    80005476:	40d0                	lw	a2,4(s1)
    80005478:	fd040593          	addi	a1,s0,-48
    8000547c:	854a                	mv	a0,s2
    8000547e:	ffffe097          	auipc	ra,0xffffe
    80005482:	726080e7          	jalr	1830(ra) # 80003ba4 <dirlink>
    80005486:	04054663          	bltz	a0,800054d2 <sys_link+0x108>
  iunlockput(dp);
    8000548a:	854a                	mv	a0,s2
    8000548c:	ffffe097          	auipc	ra,0xffffe
    80005490:	284080e7          	jalr	644(ra) # 80003710 <iunlockput>
  iput(ip);
    80005494:	8526                	mv	a0,s1
    80005496:	ffffe097          	auipc	ra,0xffffe
    8000549a:	14a080e7          	jalr	330(ra) # 800035e0 <iput>
  end_op(ROOTDEV);
    8000549e:	4501                	li	a0,0
    800054a0:	fffff097          	auipc	ra,0xfffff
    800054a4:	b8a080e7          	jalr	-1142(ra) # 8000402a <end_op>
  return 0;
    800054a8:	4781                	li	a5,0
    800054aa:	a09d                	j	80005510 <sys_link+0x146>
    end_op(ROOTDEV);
    800054ac:	4501                	li	a0,0
    800054ae:	fffff097          	auipc	ra,0xfffff
    800054b2:	b7c080e7          	jalr	-1156(ra) # 8000402a <end_op>
    return -1;
    800054b6:	57fd                	li	a5,-1
    800054b8:	a8a1                	j	80005510 <sys_link+0x146>
    iunlockput(ip);
    800054ba:	8526                	mv	a0,s1
    800054bc:	ffffe097          	auipc	ra,0xffffe
    800054c0:	254080e7          	jalr	596(ra) # 80003710 <iunlockput>
    end_op(ROOTDEV);
    800054c4:	4501                	li	a0,0
    800054c6:	fffff097          	auipc	ra,0xfffff
    800054ca:	b64080e7          	jalr	-1180(ra) # 8000402a <end_op>
    return -1;
    800054ce:	57fd                	li	a5,-1
    800054d0:	a081                	j	80005510 <sys_link+0x146>
    iunlockput(dp);
    800054d2:	854a                	mv	a0,s2
    800054d4:	ffffe097          	auipc	ra,0xffffe
    800054d8:	23c080e7          	jalr	572(ra) # 80003710 <iunlockput>
  ilock(ip);
    800054dc:	8526                	mv	a0,s1
    800054de:	ffffe097          	auipc	ra,0xffffe
    800054e2:	ff2080e7          	jalr	-14(ra) # 800034d0 <ilock>
  ip->nlink--;
    800054e6:	04a4d783          	lhu	a5,74(s1)
    800054ea:	37fd                	addiw	a5,a5,-1
    800054ec:	04f49523          	sh	a5,74(s1)
  iupdate(ip);
    800054f0:	8526                	mv	a0,s1
    800054f2:	ffffe097          	auipc	ra,0xffffe
    800054f6:	f12080e7          	jalr	-238(ra) # 80003404 <iupdate>
  iunlockput(ip);
    800054fa:	8526                	mv	a0,s1
    800054fc:	ffffe097          	auipc	ra,0xffffe
    80005500:	214080e7          	jalr	532(ra) # 80003710 <iunlockput>
  end_op(ROOTDEV);
    80005504:	4501                	li	a0,0
    80005506:	fffff097          	auipc	ra,0xfffff
    8000550a:	b24080e7          	jalr	-1244(ra) # 8000402a <end_op>
  return -1;
    8000550e:	57fd                	li	a5,-1
}
    80005510:	853e                	mv	a0,a5
    80005512:	70b2                	ld	ra,296(sp)
    80005514:	7412                	ld	s0,288(sp)
    80005516:	64f2                	ld	s1,280(sp)
    80005518:	6952                	ld	s2,272(sp)
    8000551a:	6155                	addi	sp,sp,304
    8000551c:	8082                	ret

000000008000551e <sys_unlink>:
{
    8000551e:	7151                	addi	sp,sp,-240
    80005520:	f586                	sd	ra,232(sp)
    80005522:	f1a2                	sd	s0,224(sp)
    80005524:	eda6                	sd	s1,216(sp)
    80005526:	e9ca                	sd	s2,208(sp)
    80005528:	e5ce                	sd	s3,200(sp)
    8000552a:	1980                	addi	s0,sp,240
  if(argstr(0, path, MAXPATH) < 0)
    8000552c:	08000613          	li	a2,128
    80005530:	f3040593          	addi	a1,s0,-208
    80005534:	4501                	li	a0,0
    80005536:	ffffd097          	auipc	ra,0xffffd
    8000553a:	42e080e7          	jalr	1070(ra) # 80002964 <argstr>
    8000553e:	18054263          	bltz	a0,800056c2 <sys_unlink+0x1a4>
  begin_op(ROOTDEV);
    80005542:	4501                	li	a0,0
    80005544:	fffff097          	auipc	ra,0xfffff
    80005548:	a3c080e7          	jalr	-1476(ra) # 80003f80 <begin_op>
  if((dp = nameiparent(path, name)) == 0){
    8000554c:	fb040593          	addi	a1,s0,-80
    80005550:	f3040513          	addi	a0,s0,-208
    80005554:	ffffe097          	auipc	ra,0xffffe
    80005558:	730080e7          	jalr	1840(ra) # 80003c84 <nameiparent>
    8000555c:	89aa                	mv	s3,a0
    8000555e:	cd61                	beqz	a0,80005636 <sys_unlink+0x118>
  ilock(dp);
    80005560:	ffffe097          	auipc	ra,0xffffe
    80005564:	f70080e7          	jalr	-144(ra) # 800034d0 <ilock>
  if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0)
    80005568:	00002597          	auipc	a1,0x2
    8000556c:	21858593          	addi	a1,a1,536 # 80007780 <userret+0x6f0>
    80005570:	fb040513          	addi	a0,s0,-80
    80005574:	ffffe097          	auipc	ra,0xffffe
    80005578:	3fe080e7          	jalr	1022(ra) # 80003972 <namecmp>
    8000557c:	14050a63          	beqz	a0,800056d0 <sys_unlink+0x1b2>
    80005580:	00002597          	auipc	a1,0x2
    80005584:	20858593          	addi	a1,a1,520 # 80007788 <userret+0x6f8>
    80005588:	fb040513          	addi	a0,s0,-80
    8000558c:	ffffe097          	auipc	ra,0xffffe
    80005590:	3e6080e7          	jalr	998(ra) # 80003972 <namecmp>
    80005594:	12050e63          	beqz	a0,800056d0 <sys_unlink+0x1b2>
  if((ip = dirlookup(dp, name, &off)) == 0)
    80005598:	f2c40613          	addi	a2,s0,-212
    8000559c:	fb040593          	addi	a1,s0,-80
    800055a0:	854e                	mv	a0,s3
    800055a2:	ffffe097          	auipc	ra,0xffffe
    800055a6:	3ea080e7          	jalr	1002(ra) # 8000398c <dirlookup>
    800055aa:	84aa                	mv	s1,a0
    800055ac:	12050263          	beqz	a0,800056d0 <sys_unlink+0x1b2>
  ilock(ip);
    800055b0:	ffffe097          	auipc	ra,0xffffe
    800055b4:	f20080e7          	jalr	-224(ra) # 800034d0 <ilock>
  if(ip->nlink < 1)
    800055b8:	04a49783          	lh	a5,74(s1)
    800055bc:	08f05463          	blez	a5,80005644 <sys_unlink+0x126>
  if(ip->type == T_DIR && !isdirempty(ip)){
    800055c0:	04449703          	lh	a4,68(s1)
    800055c4:	4785                	li	a5,1
    800055c6:	08f70763          	beq	a4,a5,80005654 <sys_unlink+0x136>
  memset(&de, 0, sizeof(de));
    800055ca:	4641                	li	a2,16
    800055cc:	4581                	li	a1,0
    800055ce:	fc040513          	addi	a0,s0,-64
    800055d2:	ffffb097          	auipc	ra,0xffffb
    800055d6:	5f4080e7          	jalr	1524(ra) # 80000bc6 <memset>
  if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    800055da:	4741                	li	a4,16
    800055dc:	f2c42683          	lw	a3,-212(s0)
    800055e0:	fc040613          	addi	a2,s0,-64
    800055e4:	4581                	li	a1,0
    800055e6:	854e                	mv	a0,s3
    800055e8:	ffffe097          	auipc	ra,0xffffe
    800055ec:	26e080e7          	jalr	622(ra) # 80003856 <writei>
    800055f0:	47c1                	li	a5,16
    800055f2:	0af51563          	bne	a0,a5,8000569c <sys_unlink+0x17e>
  if(ip->type == T_DIR){
    800055f6:	04449703          	lh	a4,68(s1)
    800055fa:	4785                	li	a5,1
    800055fc:	0af70863          	beq	a4,a5,800056ac <sys_unlink+0x18e>
  iunlockput(dp);
    80005600:	854e                	mv	a0,s3
    80005602:	ffffe097          	auipc	ra,0xffffe
    80005606:	10e080e7          	jalr	270(ra) # 80003710 <iunlockput>
  ip->nlink--;
    8000560a:	04a4d783          	lhu	a5,74(s1)
    8000560e:	37fd                	addiw	a5,a5,-1
    80005610:	04f49523          	sh	a5,74(s1)
  iupdate(ip);
    80005614:	8526                	mv	a0,s1
    80005616:	ffffe097          	auipc	ra,0xffffe
    8000561a:	dee080e7          	jalr	-530(ra) # 80003404 <iupdate>
  iunlockput(ip);
    8000561e:	8526                	mv	a0,s1
    80005620:	ffffe097          	auipc	ra,0xffffe
    80005624:	0f0080e7          	jalr	240(ra) # 80003710 <iunlockput>
  end_op(ROOTDEV);
    80005628:	4501                	li	a0,0
    8000562a:	fffff097          	auipc	ra,0xfffff
    8000562e:	a00080e7          	jalr	-1536(ra) # 8000402a <end_op>
  return 0;
    80005632:	4501                	li	a0,0
    80005634:	a84d                	j	800056e6 <sys_unlink+0x1c8>
    end_op(ROOTDEV);
    80005636:	4501                	li	a0,0
    80005638:	fffff097          	auipc	ra,0xfffff
    8000563c:	9f2080e7          	jalr	-1550(ra) # 8000402a <end_op>
    return -1;
    80005640:	557d                	li	a0,-1
    80005642:	a055                	j	800056e6 <sys_unlink+0x1c8>
    panic("unlink: nlink < 1");
    80005644:	00002517          	auipc	a0,0x2
    80005648:	16c50513          	addi	a0,a0,364 # 800077b0 <userret+0x720>
    8000564c:	ffffb097          	auipc	ra,0xffffb
    80005650:	f32080e7          	jalr	-206(ra) # 8000057e <panic>
  for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){
    80005654:	44f8                	lw	a4,76(s1)
    80005656:	02000793          	li	a5,32
    8000565a:	f6e7f8e3          	bleu	a4,a5,800055ca <sys_unlink+0xac>
    8000565e:	02000913          	li	s2,32
    if(readi(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80005662:	4741                	li	a4,16
    80005664:	86ca                	mv	a3,s2
    80005666:	f1840613          	addi	a2,s0,-232
    8000566a:	4581                	li	a1,0
    8000566c:	8526                	mv	a0,s1
    8000566e:	ffffe097          	auipc	ra,0xffffe
    80005672:	0f4080e7          	jalr	244(ra) # 80003762 <readi>
    80005676:	47c1                	li	a5,16
    80005678:	00f51a63          	bne	a0,a5,8000568c <sys_unlink+0x16e>
    if(de.inum != 0)
    8000567c:	f1845783          	lhu	a5,-232(s0)
    80005680:	e3b9                	bnez	a5,800056c6 <sys_unlink+0x1a8>
  for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){
    80005682:	2941                	addiw	s2,s2,16
    80005684:	44fc                	lw	a5,76(s1)
    80005686:	fcf96ee3          	bltu	s2,a5,80005662 <sys_unlink+0x144>
    8000568a:	b781                	j	800055ca <sys_unlink+0xac>
      panic("isdirempty: readi");
    8000568c:	00002517          	auipc	a0,0x2
    80005690:	13c50513          	addi	a0,a0,316 # 800077c8 <userret+0x738>
    80005694:	ffffb097          	auipc	ra,0xffffb
    80005698:	eea080e7          	jalr	-278(ra) # 8000057e <panic>
    panic("unlink: writei");
    8000569c:	00002517          	auipc	a0,0x2
    800056a0:	14450513          	addi	a0,a0,324 # 800077e0 <userret+0x750>
    800056a4:	ffffb097          	auipc	ra,0xffffb
    800056a8:	eda080e7          	jalr	-294(ra) # 8000057e <panic>
    dp->nlink--;
    800056ac:	04a9d783          	lhu	a5,74(s3)
    800056b0:	37fd                	addiw	a5,a5,-1
    800056b2:	04f99523          	sh	a5,74(s3)
    iupdate(dp);
    800056b6:	854e                	mv	a0,s3
    800056b8:	ffffe097          	auipc	ra,0xffffe
    800056bc:	d4c080e7          	jalr	-692(ra) # 80003404 <iupdate>
    800056c0:	b781                	j	80005600 <sys_unlink+0xe2>
    return -1;
    800056c2:	557d                	li	a0,-1
    800056c4:	a00d                	j	800056e6 <sys_unlink+0x1c8>
    iunlockput(ip);
    800056c6:	8526                	mv	a0,s1
    800056c8:	ffffe097          	auipc	ra,0xffffe
    800056cc:	048080e7          	jalr	72(ra) # 80003710 <iunlockput>
  iunlockput(dp);
    800056d0:	854e                	mv	a0,s3
    800056d2:	ffffe097          	auipc	ra,0xffffe
    800056d6:	03e080e7          	jalr	62(ra) # 80003710 <iunlockput>
  end_op(ROOTDEV);
    800056da:	4501                	li	a0,0
    800056dc:	fffff097          	auipc	ra,0xfffff
    800056e0:	94e080e7          	jalr	-1714(ra) # 8000402a <end_op>
  return -1;
    800056e4:	557d                	li	a0,-1
}
    800056e6:	70ae                	ld	ra,232(sp)
    800056e8:	740e                	ld	s0,224(sp)
    800056ea:	64ee                	ld	s1,216(sp)
    800056ec:	694e                	ld	s2,208(sp)
    800056ee:	69ae                	ld	s3,200(sp)
    800056f0:	616d                	addi	sp,sp,240
    800056f2:	8082                	ret

00000000800056f4 <sys_open>:

uint64
sys_open(void)
{
    800056f4:	7131                	addi	sp,sp,-192
    800056f6:	fd06                	sd	ra,184(sp)
    800056f8:	f922                	sd	s0,176(sp)
    800056fa:	f526                	sd	s1,168(sp)
    800056fc:	f14a                	sd	s2,160(sp)
    800056fe:	ed4e                	sd	s3,152(sp)
    80005700:	0180                	addi	s0,sp,192
  char path[MAXPATH];
  int fd, omode;
  struct file *f;
  struct inode *ip;

  if(argstr(0, path, MAXPATH) < 0 || argint(1, &omode) < 0)
    80005702:	08000613          	li	a2,128
    80005706:	f5040593          	addi	a1,s0,-176
    8000570a:	4501                	li	a0,0
    8000570c:	ffffd097          	auipc	ra,0xffffd
    80005710:	258080e7          	jalr	600(ra) # 80002964 <argstr>
    return -1;
    80005714:	54fd                	li	s1,-1
  if(argstr(0, path, MAXPATH) < 0 || argint(1, &omode) < 0)
    80005716:	0a054963          	bltz	a0,800057c8 <sys_open+0xd4>
    8000571a:	f4c40593          	addi	a1,s0,-180
    8000571e:	4505                	li	a0,1
    80005720:	ffffd097          	auipc	ra,0xffffd
    80005724:	200080e7          	jalr	512(ra) # 80002920 <argint>
    80005728:	0a054063          	bltz	a0,800057c8 <sys_open+0xd4>

  begin_op(ROOTDEV);
    8000572c:	4501                	li	a0,0
    8000572e:	fffff097          	auipc	ra,0xfffff
    80005732:	852080e7          	jalr	-1966(ra) # 80003f80 <begin_op>

  if(omode & O_CREATE){
    80005736:	f4c42783          	lw	a5,-180(s0)
    8000573a:	2007f793          	andi	a5,a5,512
    8000573e:	c3dd                	beqz	a5,800057e4 <sys_open+0xf0>
    ip = create(path, T_FILE, 0, 0);
    80005740:	4681                	li	a3,0
    80005742:	4601                	li	a2,0
    80005744:	4589                	li	a1,2
    80005746:	f5040513          	addi	a0,s0,-176
    8000574a:	00000097          	auipc	ra,0x0
    8000574e:	962080e7          	jalr	-1694(ra) # 800050ac <create>
    80005752:	892a                	mv	s2,a0
    if(ip == 0){
    80005754:	c151                	beqz	a0,800057d8 <sys_open+0xe4>
      end_op(ROOTDEV);
      return -1;
    }
  }

  if(ip->type == T_DEVICE && (ip->major < 0 || ip->major >= NDEV)){
    80005756:	04491703          	lh	a4,68(s2)
    8000575a:	478d                	li	a5,3
    8000575c:	00f71763          	bne	a4,a5,8000576a <sys_open+0x76>
    80005760:	04695703          	lhu	a4,70(s2)
    80005764:	47a5                	li	a5,9
    80005766:	0ce7e663          	bltu	a5,a4,80005832 <sys_open+0x13e>
    iunlockput(ip);
    end_op(ROOTDEV);
    return -1;
  }

  if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){
    8000576a:	fffff097          	auipc	ra,0xfffff
    8000576e:	da0080e7          	jalr	-608(ra) # 8000450a <filealloc>
    80005772:	89aa                	mv	s3,a0
    80005774:	c57d                	beqz	a0,80005862 <sys_open+0x16e>
    80005776:	00000097          	auipc	ra,0x0
    8000577a:	8ee080e7          	jalr	-1810(ra) # 80005064 <fdalloc>
    8000577e:	84aa                	mv	s1,a0
    80005780:	0c054c63          	bltz	a0,80005858 <sys_open+0x164>
    iunlockput(ip);
    end_op(ROOTDEV);
    return -1;
  }

  if(ip->type == T_DEVICE){
    80005784:	04491703          	lh	a4,68(s2)
    80005788:	478d                	li	a5,3
    8000578a:	0cf70063          	beq	a4,a5,8000584a <sys_open+0x156>
    f->type = FD_DEVICE;
    f->major = ip->major;
  } else {
    f->type = FD_INODE;
    8000578e:	4789                	li	a5,2
    80005790:	00f9a023          	sw	a5,0(s3)
    f->off = 0;
    80005794:	0209a023          	sw	zero,32(s3)
  }
  f->ip = ip;
    80005798:	0129bc23          	sd	s2,24(s3)
  f->readable = !(omode & O_WRONLY);
    8000579c:	f4c42783          	lw	a5,-180(s0)
    800057a0:	0017c713          	xori	a4,a5,1
    800057a4:	8b05                	andi	a4,a4,1
    800057a6:	00e98423          	sb	a4,8(s3)
  f->writable = (omode & O_WRONLY) || (omode & O_RDWR);
    800057aa:	8b8d                	andi	a5,a5,3
    800057ac:	00f037b3          	snez	a5,a5
    800057b0:	00f984a3          	sb	a5,9(s3)

  iunlock(ip);
    800057b4:	854a                	mv	a0,s2
    800057b6:	ffffe097          	auipc	ra,0xffffe
    800057ba:	dde080e7          	jalr	-546(ra) # 80003594 <iunlock>
  end_op(ROOTDEV);
    800057be:	4501                	li	a0,0
    800057c0:	fffff097          	auipc	ra,0xfffff
    800057c4:	86a080e7          	jalr	-1942(ra) # 8000402a <end_op>

  return fd;
}
    800057c8:	8526                	mv	a0,s1
    800057ca:	70ea                	ld	ra,184(sp)
    800057cc:	744a                	ld	s0,176(sp)
    800057ce:	74aa                	ld	s1,168(sp)
    800057d0:	790a                	ld	s2,160(sp)
    800057d2:	69ea                	ld	s3,152(sp)
    800057d4:	6129                	addi	sp,sp,192
    800057d6:	8082                	ret
      end_op(ROOTDEV);
    800057d8:	4501                	li	a0,0
    800057da:	fffff097          	auipc	ra,0xfffff
    800057de:	850080e7          	jalr	-1968(ra) # 8000402a <end_op>
      return -1;
    800057e2:	b7dd                	j	800057c8 <sys_open+0xd4>
    if((ip = namei(path)) == 0){
    800057e4:	f5040513          	addi	a0,s0,-176
    800057e8:	ffffe097          	auipc	ra,0xffffe
    800057ec:	47e080e7          	jalr	1150(ra) # 80003c66 <namei>
    800057f0:	892a                	mv	s2,a0
    800057f2:	c90d                	beqz	a0,80005824 <sys_open+0x130>
    ilock(ip);
    800057f4:	ffffe097          	auipc	ra,0xffffe
    800057f8:	cdc080e7          	jalr	-804(ra) # 800034d0 <ilock>
    if(ip->type == T_DIR && omode != O_RDONLY){
    800057fc:	04491703          	lh	a4,68(s2)
    80005800:	4785                	li	a5,1
    80005802:	f4f71ae3          	bne	a4,a5,80005756 <sys_open+0x62>
    80005806:	f4c42783          	lw	a5,-180(s0)
    8000580a:	d3a5                	beqz	a5,8000576a <sys_open+0x76>
      iunlockput(ip);
    8000580c:	854a                	mv	a0,s2
    8000580e:	ffffe097          	auipc	ra,0xffffe
    80005812:	f02080e7          	jalr	-254(ra) # 80003710 <iunlockput>
      end_op(ROOTDEV);
    80005816:	4501                	li	a0,0
    80005818:	fffff097          	auipc	ra,0xfffff
    8000581c:	812080e7          	jalr	-2030(ra) # 8000402a <end_op>
      return -1;
    80005820:	54fd                	li	s1,-1
    80005822:	b75d                	j	800057c8 <sys_open+0xd4>
      end_op(ROOTDEV);
    80005824:	4501                	li	a0,0
    80005826:	fffff097          	auipc	ra,0xfffff
    8000582a:	804080e7          	jalr	-2044(ra) # 8000402a <end_op>
      return -1;
    8000582e:	54fd                	li	s1,-1
    80005830:	bf61                	j	800057c8 <sys_open+0xd4>
    iunlockput(ip);
    80005832:	854a                	mv	a0,s2
    80005834:	ffffe097          	auipc	ra,0xffffe
    80005838:	edc080e7          	jalr	-292(ra) # 80003710 <iunlockput>
    end_op(ROOTDEV);
    8000583c:	4501                	li	a0,0
    8000583e:	ffffe097          	auipc	ra,0xffffe
    80005842:	7ec080e7          	jalr	2028(ra) # 8000402a <end_op>
    return -1;
    80005846:	54fd                	li	s1,-1
    80005848:	b741                	j	800057c8 <sys_open+0xd4>
    f->type = FD_DEVICE;
    8000584a:	00f9a023          	sw	a5,0(s3)
    f->major = ip->major;
    8000584e:	04691783          	lh	a5,70(s2)
    80005852:	02f99223          	sh	a5,36(s3)
    80005856:	b789                	j	80005798 <sys_open+0xa4>
      fileclose(f);
    80005858:	854e                	mv	a0,s3
    8000585a:	fffff097          	auipc	ra,0xfffff
    8000585e:	d80080e7          	jalr	-640(ra) # 800045da <fileclose>
    iunlockput(ip);
    80005862:	854a                	mv	a0,s2
    80005864:	ffffe097          	auipc	ra,0xffffe
    80005868:	eac080e7          	jalr	-340(ra) # 80003710 <iunlockput>
    end_op(ROOTDEV);
    8000586c:	4501                	li	a0,0
    8000586e:	ffffe097          	auipc	ra,0xffffe
    80005872:	7bc080e7          	jalr	1980(ra) # 8000402a <end_op>
    return -1;
    80005876:	54fd                	li	s1,-1
    80005878:	bf81                	j	800057c8 <sys_open+0xd4>

000000008000587a <sys_mkdir>:

uint64
sys_mkdir(void)
{
    8000587a:	7175                	addi	sp,sp,-144
    8000587c:	e506                	sd	ra,136(sp)
    8000587e:	e122                	sd	s0,128(sp)
    80005880:	0900                	addi	s0,sp,144
  char path[MAXPATH];
  struct inode *ip;

  begin_op(ROOTDEV);
    80005882:	4501                	li	a0,0
    80005884:	ffffe097          	auipc	ra,0xffffe
    80005888:	6fc080e7          	jalr	1788(ra) # 80003f80 <begin_op>
  if(argstr(0, path, MAXPATH) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){
    8000588c:	08000613          	li	a2,128
    80005890:	f7040593          	addi	a1,s0,-144
    80005894:	4501                	li	a0,0
    80005896:	ffffd097          	auipc	ra,0xffffd
    8000589a:	0ce080e7          	jalr	206(ra) # 80002964 <argstr>
    8000589e:	02054a63          	bltz	a0,800058d2 <sys_mkdir+0x58>
    800058a2:	4681                	li	a3,0
    800058a4:	4601                	li	a2,0
    800058a6:	4585                	li	a1,1
    800058a8:	f7040513          	addi	a0,s0,-144
    800058ac:	00000097          	auipc	ra,0x0
    800058b0:	800080e7          	jalr	-2048(ra) # 800050ac <create>
    800058b4:	cd19                	beqz	a0,800058d2 <sys_mkdir+0x58>
    end_op(ROOTDEV);
    return -1;
  }
  iunlockput(ip);
    800058b6:	ffffe097          	auipc	ra,0xffffe
    800058ba:	e5a080e7          	jalr	-422(ra) # 80003710 <iunlockput>
  end_op(ROOTDEV);
    800058be:	4501                	li	a0,0
    800058c0:	ffffe097          	auipc	ra,0xffffe
    800058c4:	76a080e7          	jalr	1898(ra) # 8000402a <end_op>
  return 0;
    800058c8:	4501                	li	a0,0
}
    800058ca:	60aa                	ld	ra,136(sp)
    800058cc:	640a                	ld	s0,128(sp)
    800058ce:	6149                	addi	sp,sp,144
    800058d0:	8082                	ret
    end_op(ROOTDEV);
    800058d2:	4501                	li	a0,0
    800058d4:	ffffe097          	auipc	ra,0xffffe
    800058d8:	756080e7          	jalr	1878(ra) # 8000402a <end_op>
    return -1;
    800058dc:	557d                	li	a0,-1
    800058de:	b7f5                	j	800058ca <sys_mkdir+0x50>

00000000800058e0 <sys_mknod>:

uint64
sys_mknod(void)
{
    800058e0:	7135                	addi	sp,sp,-160
    800058e2:	ed06                	sd	ra,152(sp)
    800058e4:	e922                	sd	s0,144(sp)
    800058e6:	1100                	addi	s0,sp,160
  struct inode *ip;
  char path[MAXPATH];
  int major, minor;

  begin_op(ROOTDEV);
    800058e8:	4501                	li	a0,0
    800058ea:	ffffe097          	auipc	ra,0xffffe
    800058ee:	696080e7          	jalr	1686(ra) # 80003f80 <begin_op>
  if((argstr(0, path, MAXPATH)) < 0 ||
    800058f2:	08000613          	li	a2,128
    800058f6:	f7040593          	addi	a1,s0,-144
    800058fa:	4501                	li	a0,0
    800058fc:	ffffd097          	auipc	ra,0xffffd
    80005900:	068080e7          	jalr	104(ra) # 80002964 <argstr>
    80005904:	04054b63          	bltz	a0,8000595a <sys_mknod+0x7a>
     argint(1, &major) < 0 ||
    80005908:	f6c40593          	addi	a1,s0,-148
    8000590c:	4505                	li	a0,1
    8000590e:	ffffd097          	auipc	ra,0xffffd
    80005912:	012080e7          	jalr	18(ra) # 80002920 <argint>
  if((argstr(0, path, MAXPATH)) < 0 ||
    80005916:	04054263          	bltz	a0,8000595a <sys_mknod+0x7a>
     argint(2, &minor) < 0 ||
    8000591a:	f6840593          	addi	a1,s0,-152
    8000591e:	4509                	li	a0,2
    80005920:	ffffd097          	auipc	ra,0xffffd
    80005924:	000080e7          	jalr	ra # 80002920 <argint>
     argint(1, &major) < 0 ||
    80005928:	02054963          	bltz	a0,8000595a <sys_mknod+0x7a>
     (ip = create(path, T_DEVICE, major, minor)) == 0){
    8000592c:	f6841683          	lh	a3,-152(s0)
    80005930:	f6c41603          	lh	a2,-148(s0)
    80005934:	458d                	li	a1,3
    80005936:	f7040513          	addi	a0,s0,-144
    8000593a:	fffff097          	auipc	ra,0xfffff
    8000593e:	772080e7          	jalr	1906(ra) # 800050ac <create>
     argint(2, &minor) < 0 ||
    80005942:	cd01                	beqz	a0,8000595a <sys_mknod+0x7a>
    end_op(ROOTDEV);
    return -1;
  }
  iunlockput(ip);
    80005944:	ffffe097          	auipc	ra,0xffffe
    80005948:	dcc080e7          	jalr	-564(ra) # 80003710 <iunlockput>
  end_op(ROOTDEV);
    8000594c:	4501                	li	a0,0
    8000594e:	ffffe097          	auipc	ra,0xffffe
    80005952:	6dc080e7          	jalr	1756(ra) # 8000402a <end_op>
  return 0;
    80005956:	4501                	li	a0,0
    80005958:	a039                	j	80005966 <sys_mknod+0x86>
    end_op(ROOTDEV);
    8000595a:	4501                	li	a0,0
    8000595c:	ffffe097          	auipc	ra,0xffffe
    80005960:	6ce080e7          	jalr	1742(ra) # 8000402a <end_op>
    return -1;
    80005964:	557d                	li	a0,-1
}
    80005966:	60ea                	ld	ra,152(sp)
    80005968:	644a                	ld	s0,144(sp)
    8000596a:	610d                	addi	sp,sp,160
    8000596c:	8082                	ret

000000008000596e <sys_chdir>:

uint64
sys_chdir(void)
{
    8000596e:	7135                	addi	sp,sp,-160
    80005970:	ed06                	sd	ra,152(sp)
    80005972:	e922                	sd	s0,144(sp)
    80005974:	e526                	sd	s1,136(sp)
    80005976:	e14a                	sd	s2,128(sp)
    80005978:	1100                	addi	s0,sp,160
  char path[MAXPATH];
  struct inode *ip;
  struct proc *p = myproc();
    8000597a:	ffffc097          	auipc	ra,0xffffc
    8000597e:	f24080e7          	jalr	-220(ra) # 8000189e <myproc>
    80005982:	892a                	mv	s2,a0
  
  begin_op(ROOTDEV);
    80005984:	4501                	li	a0,0
    80005986:	ffffe097          	auipc	ra,0xffffe
    8000598a:	5fa080e7          	jalr	1530(ra) # 80003f80 <begin_op>
  if(argstr(0, path, MAXPATH) < 0 || (ip = namei(path)) == 0){
    8000598e:	08000613          	li	a2,128
    80005992:	f6040593          	addi	a1,s0,-160
    80005996:	4501                	li	a0,0
    80005998:	ffffd097          	auipc	ra,0xffffd
    8000599c:	fcc080e7          	jalr	-52(ra) # 80002964 <argstr>
    800059a0:	04054c63          	bltz	a0,800059f8 <sys_chdir+0x8a>
    800059a4:	f6040513          	addi	a0,s0,-160
    800059a8:	ffffe097          	auipc	ra,0xffffe
    800059ac:	2be080e7          	jalr	702(ra) # 80003c66 <namei>
    800059b0:	84aa                	mv	s1,a0
    800059b2:	c139                	beqz	a0,800059f8 <sys_chdir+0x8a>
    end_op(ROOTDEV);
    return -1;
  }
  ilock(ip);
    800059b4:	ffffe097          	auipc	ra,0xffffe
    800059b8:	b1c080e7          	jalr	-1252(ra) # 800034d0 <ilock>
  if(ip->type != T_DIR){
    800059bc:	04449703          	lh	a4,68(s1)
    800059c0:	4785                	li	a5,1
    800059c2:	04f71263          	bne	a4,a5,80005a06 <sys_chdir+0x98>
    iunlockput(ip);
    end_op(ROOTDEV);
    return -1;
  }
  iunlock(ip);
    800059c6:	8526                	mv	a0,s1
    800059c8:	ffffe097          	auipc	ra,0xffffe
    800059cc:	bcc080e7          	jalr	-1076(ra) # 80003594 <iunlock>
  iput(p->cwd);
    800059d0:	14893503          	ld	a0,328(s2)
    800059d4:	ffffe097          	auipc	ra,0xffffe
    800059d8:	c0c080e7          	jalr	-1012(ra) # 800035e0 <iput>
  end_op(ROOTDEV);
    800059dc:	4501                	li	a0,0
    800059de:	ffffe097          	auipc	ra,0xffffe
    800059e2:	64c080e7          	jalr	1612(ra) # 8000402a <end_op>
  p->cwd = ip;
    800059e6:	14993423          	sd	s1,328(s2)
  return 0;
    800059ea:	4501                	li	a0,0
}
    800059ec:	60ea                	ld	ra,152(sp)
    800059ee:	644a                	ld	s0,144(sp)
    800059f0:	64aa                	ld	s1,136(sp)
    800059f2:	690a                	ld	s2,128(sp)
    800059f4:	610d                	addi	sp,sp,160
    800059f6:	8082                	ret
    end_op(ROOTDEV);
    800059f8:	4501                	li	a0,0
    800059fa:	ffffe097          	auipc	ra,0xffffe
    800059fe:	630080e7          	jalr	1584(ra) # 8000402a <end_op>
    return -1;
    80005a02:	557d                	li	a0,-1
    80005a04:	b7e5                	j	800059ec <sys_chdir+0x7e>
    iunlockput(ip);
    80005a06:	8526                	mv	a0,s1
    80005a08:	ffffe097          	auipc	ra,0xffffe
    80005a0c:	d08080e7          	jalr	-760(ra) # 80003710 <iunlockput>
    end_op(ROOTDEV);
    80005a10:	4501                	li	a0,0
    80005a12:	ffffe097          	auipc	ra,0xffffe
    80005a16:	618080e7          	jalr	1560(ra) # 8000402a <end_op>
    return -1;
    80005a1a:	557d                	li	a0,-1
    80005a1c:	bfc1                	j	800059ec <sys_chdir+0x7e>

0000000080005a1e <sys_exec>:

uint64
sys_exec(void)
{
    80005a1e:	7145                	addi	sp,sp,-464
    80005a20:	e786                	sd	ra,456(sp)
    80005a22:	e3a2                	sd	s0,448(sp)
    80005a24:	ff26                	sd	s1,440(sp)
    80005a26:	fb4a                	sd	s2,432(sp)
    80005a28:	f74e                	sd	s3,424(sp)
    80005a2a:	f352                	sd	s4,416(sp)
    80005a2c:	ef56                	sd	s5,408(sp)
    80005a2e:	0b80                	addi	s0,sp,464
  char path[MAXPATH], *argv[MAXARG];
  int i;
  uint64 uargv, uarg;

  if(argstr(0, path, MAXPATH) < 0 || argaddr(1, &uargv) < 0){
    80005a30:	08000613          	li	a2,128
    80005a34:	f4040593          	addi	a1,s0,-192
    80005a38:	4501                	li	a0,0
    80005a3a:	ffffd097          	auipc	ra,0xffffd
    80005a3e:	f2a080e7          	jalr	-214(ra) # 80002964 <argstr>
    80005a42:	0c054f63          	bltz	a0,80005b20 <sys_exec+0x102>
    80005a46:	e3840593          	addi	a1,s0,-456
    80005a4a:	4505                	li	a0,1
    80005a4c:	ffffd097          	auipc	ra,0xffffd
    80005a50:	ef6080e7          	jalr	-266(ra) # 80002942 <argaddr>
    80005a54:	0e054063          	bltz	a0,80005b34 <sys_exec+0x116>
    return -1;
  }
  memset(argv, 0, sizeof(argv));
    80005a58:	e4040913          	addi	s2,s0,-448
    80005a5c:	10000613          	li	a2,256
    80005a60:	4581                	li	a1,0
    80005a62:	854a                	mv	a0,s2
    80005a64:	ffffb097          	auipc	ra,0xffffb
    80005a68:	162080e7          	jalr	354(ra) # 80000bc6 <memset>
  for(i=0;; i++){
    if(i >= NELEM(argv)){
    80005a6c:	8a4a                	mv	s4,s2
  memset(argv, 0, sizeof(argv));
    80005a6e:	4481                	li	s1,0
    if(i >= NELEM(argv)){
    80005a70:	02000a93          	li	s5,32
    80005a74:	0004899b          	sext.w	s3,s1
      return -1;
    }
    if(fetchaddr(uargv+sizeof(uint64)*i, (uint64*)&uarg) < 0){
    80005a78:	00349513          	slli	a0,s1,0x3
    80005a7c:	e3040593          	addi	a1,s0,-464
    80005a80:	e3843783          	ld	a5,-456(s0)
    80005a84:	953e                	add	a0,a0,a5
    80005a86:	ffffd097          	auipc	ra,0xffffd
    80005a8a:	dfe080e7          	jalr	-514(ra) # 80002884 <fetchaddr>
    80005a8e:	0a054563          	bltz	a0,80005b38 <sys_exec+0x11a>
      return -1;
    }
    if(uarg == 0){
    80005a92:	e3043783          	ld	a5,-464(s0)
    80005a96:	cb85                	beqz	a5,80005ac6 <sys_exec+0xa8>
      argv[i] = 0;
      break;
    }
    argv[i] = kalloc();
    80005a98:	ffffb097          	auipc	ra,0xffffb
    80005a9c:	efa080e7          	jalr	-262(ra) # 80000992 <kalloc>
    80005aa0:	85aa                	mv	a1,a0
    80005aa2:	00a93023          	sd	a0,0(s2)
    if(argv[i] == 0)
    80005aa6:	c52d                	beqz	a0,80005b10 <sys_exec+0xf2>
      panic("sys_exec kalloc");
    if(fetchstr(uarg, argv[i], PGSIZE) < 0){
    80005aa8:	6605                	lui	a2,0x1
    80005aaa:	e3043503          	ld	a0,-464(s0)
    80005aae:	ffffd097          	auipc	ra,0xffffd
    80005ab2:	e2a080e7          	jalr	-470(ra) # 800028d8 <fetchstr>
    80005ab6:	08054363          	bltz	a0,80005b3c <sys_exec+0x11e>
    if(i >= NELEM(argv)){
    80005aba:	0485                	addi	s1,s1,1
    80005abc:	0921                	addi	s2,s2,8
    80005abe:	fb549be3          	bne	s1,s5,80005a74 <sys_exec+0x56>
      return -1;
    80005ac2:	557d                	li	a0,-1
    80005ac4:	a8b9                	j	80005b22 <sys_exec+0x104>
      argv[i] = 0;
    80005ac6:	098e                	slli	s3,s3,0x3
    80005ac8:	fc040793          	addi	a5,s0,-64
    80005acc:	99be                	add	s3,s3,a5
    80005ace:	e809b023          	sd	zero,-384(s3)
      return -1;
    }
  }

  int ret = exec(path, argv);
    80005ad2:	e4040593          	addi	a1,s0,-448
    80005ad6:	f4040513          	addi	a0,s0,-192
    80005ada:	fffff097          	auipc	ra,0xfffff
    80005ade:	196080e7          	jalr	406(ra) # 80004c70 <exec>
    80005ae2:	892a                	mv	s2,a0

  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005ae4:	e4043503          	ld	a0,-448(s0)
    80005ae8:	c115                	beqz	a0,80005b0c <sys_exec+0xee>
    kfree(argv[i]);
    80005aea:	ffffb097          	auipc	ra,0xffffb
    80005aee:	daa080e7          	jalr	-598(ra) # 80000894 <kfree>
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005af2:	e4840493          	addi	s1,s0,-440
    80005af6:	100a0a13          	addi	s4,s4,256
    80005afa:	6088                	ld	a0,0(s1)
    80005afc:	c901                	beqz	a0,80005b0c <sys_exec+0xee>
    kfree(argv[i]);
    80005afe:	ffffb097          	auipc	ra,0xffffb
    80005b02:	d96080e7          	jalr	-618(ra) # 80000894 <kfree>
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005b06:	04a1                	addi	s1,s1,8
    80005b08:	ff4499e3          	bne	s1,s4,80005afa <sys_exec+0xdc>

  return ret;
    80005b0c:	854a                	mv	a0,s2
    80005b0e:	a811                	j	80005b22 <sys_exec+0x104>
      panic("sys_exec kalloc");
    80005b10:	00002517          	auipc	a0,0x2
    80005b14:	ce050513          	addi	a0,a0,-800 # 800077f0 <userret+0x760>
    80005b18:	ffffb097          	auipc	ra,0xffffb
    80005b1c:	a66080e7          	jalr	-1434(ra) # 8000057e <panic>
    return -1;
    80005b20:	557d                	li	a0,-1
}
    80005b22:	60be                	ld	ra,456(sp)
    80005b24:	641e                	ld	s0,448(sp)
    80005b26:	74fa                	ld	s1,440(sp)
    80005b28:	795a                	ld	s2,432(sp)
    80005b2a:	79ba                	ld	s3,424(sp)
    80005b2c:	7a1a                	ld	s4,416(sp)
    80005b2e:	6afa                	ld	s5,408(sp)
    80005b30:	6179                	addi	sp,sp,464
    80005b32:	8082                	ret
    return -1;
    80005b34:	557d                	li	a0,-1
    80005b36:	b7f5                	j	80005b22 <sys_exec+0x104>
      return -1;
    80005b38:	557d                	li	a0,-1
    80005b3a:	b7e5                	j	80005b22 <sys_exec+0x104>
      return -1;
    80005b3c:	557d                	li	a0,-1
    80005b3e:	b7d5                	j	80005b22 <sys_exec+0x104>

0000000080005b40 <sys_pipe>:

uint64
sys_pipe(void)
{
    80005b40:	7139                	addi	sp,sp,-64
    80005b42:	fc06                	sd	ra,56(sp)
    80005b44:	f822                	sd	s0,48(sp)
    80005b46:	f426                	sd	s1,40(sp)
    80005b48:	0080                	addi	s0,sp,64
  uint64 fdarray; // user pointer to array of two integers
  struct file *rf, *wf;
  int fd0, fd1;
  struct proc *p = myproc();
    80005b4a:	ffffc097          	auipc	ra,0xffffc
    80005b4e:	d54080e7          	jalr	-684(ra) # 8000189e <myproc>
    80005b52:	84aa                	mv	s1,a0

  if(argaddr(0, &fdarray) < 0)
    80005b54:	fd840593          	addi	a1,s0,-40
    80005b58:	4501                	li	a0,0
    80005b5a:	ffffd097          	auipc	ra,0xffffd
    80005b5e:	de8080e7          	jalr	-536(ra) # 80002942 <argaddr>
    return -1;
    80005b62:	57fd                	li	a5,-1
  if(argaddr(0, &fdarray) < 0)
    80005b64:	0c054f63          	bltz	a0,80005c42 <sys_pipe+0x102>
  if(pipealloc(&rf, &wf) < 0)
    80005b68:	fc840593          	addi	a1,s0,-56
    80005b6c:	fd040513          	addi	a0,s0,-48
    80005b70:	fffff097          	auipc	ra,0xfffff
    80005b74:	d9e080e7          	jalr	-610(ra) # 8000490e <pipealloc>
    return -1;
    80005b78:	57fd                	li	a5,-1
  if(pipealloc(&rf, &wf) < 0)
    80005b7a:	0c054463          	bltz	a0,80005c42 <sys_pipe+0x102>
  fd0 = -1;
    80005b7e:	fcf42223          	sw	a5,-60(s0)
  if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){
    80005b82:	fd043503          	ld	a0,-48(s0)
    80005b86:	fffff097          	auipc	ra,0xfffff
    80005b8a:	4de080e7          	jalr	1246(ra) # 80005064 <fdalloc>
    80005b8e:	fca42223          	sw	a0,-60(s0)
    80005b92:	08054b63          	bltz	a0,80005c28 <sys_pipe+0xe8>
    80005b96:	fc843503          	ld	a0,-56(s0)
    80005b9a:	fffff097          	auipc	ra,0xfffff
    80005b9e:	4ca080e7          	jalr	1226(ra) # 80005064 <fdalloc>
    80005ba2:	fca42023          	sw	a0,-64(s0)
    80005ba6:	06054863          	bltz	a0,80005c16 <sys_pipe+0xd6>
      p->ofile[fd0] = 0;
    fileclose(rf);
    fileclose(wf);
    return -1;
  }
  if(copyout(p->pagetable, fdarray, (char*)&fd0, sizeof(fd0)) < 0 ||
    80005baa:	4691                	li	a3,4
    80005bac:	fc440613          	addi	a2,s0,-60
    80005bb0:	fd843583          	ld	a1,-40(s0)
    80005bb4:	64a8                	ld	a0,72(s1)
    80005bb6:	ffffc097          	auipc	ra,0xffffc
    80005bba:	9f6080e7          	jalr	-1546(ra) # 800015ac <copyout>
    80005bbe:	02054063          	bltz	a0,80005bde <sys_pipe+0x9e>
     copyout(p->pagetable, fdarray+sizeof(fd0), (char *)&fd1, sizeof(fd1)) < 0){
    80005bc2:	4691                	li	a3,4
    80005bc4:	fc040613          	addi	a2,s0,-64
    80005bc8:	fd843583          	ld	a1,-40(s0)
    80005bcc:	0591                	addi	a1,a1,4
    80005bce:	64a8                	ld	a0,72(s1)
    80005bd0:	ffffc097          	auipc	ra,0xffffc
    80005bd4:	9dc080e7          	jalr	-1572(ra) # 800015ac <copyout>
    p->ofile[fd1] = 0;
    fileclose(rf);
    fileclose(wf);
    return -1;
  }
  return 0;
    80005bd8:	4781                	li	a5,0
  if(copyout(p->pagetable, fdarray, (char*)&fd0, sizeof(fd0)) < 0 ||
    80005bda:	06055463          	bgez	a0,80005c42 <sys_pipe+0x102>
    p->ofile[fd0] = 0;
    80005bde:	fc442783          	lw	a5,-60(s0)
    80005be2:	07e1                	addi	a5,a5,24
    80005be4:	078e                	slli	a5,a5,0x3
    80005be6:	97a6                	add	a5,a5,s1
    80005be8:	0007b423          	sd	zero,8(a5)
    p->ofile[fd1] = 0;
    80005bec:	fc042783          	lw	a5,-64(s0)
    80005bf0:	07e1                	addi	a5,a5,24
    80005bf2:	078e                	slli	a5,a5,0x3
    80005bf4:	94be                	add	s1,s1,a5
    80005bf6:	0004b423          	sd	zero,8(s1)
    fileclose(rf);
    80005bfa:	fd043503          	ld	a0,-48(s0)
    80005bfe:	fffff097          	auipc	ra,0xfffff
    80005c02:	9dc080e7          	jalr	-1572(ra) # 800045da <fileclose>
    fileclose(wf);
    80005c06:	fc843503          	ld	a0,-56(s0)
    80005c0a:	fffff097          	auipc	ra,0xfffff
    80005c0e:	9d0080e7          	jalr	-1584(ra) # 800045da <fileclose>
    return -1;
    80005c12:	57fd                	li	a5,-1
    80005c14:	a03d                	j	80005c42 <sys_pipe+0x102>
    if(fd0 >= 0)
    80005c16:	fc442783          	lw	a5,-60(s0)
    80005c1a:	0007c763          	bltz	a5,80005c28 <sys_pipe+0xe8>
      p->ofile[fd0] = 0;
    80005c1e:	07e1                	addi	a5,a5,24
    80005c20:	078e                	slli	a5,a5,0x3
    80005c22:	94be                	add	s1,s1,a5
    80005c24:	0004b423          	sd	zero,8(s1)
    fileclose(rf);
    80005c28:	fd043503          	ld	a0,-48(s0)
    80005c2c:	fffff097          	auipc	ra,0xfffff
    80005c30:	9ae080e7          	jalr	-1618(ra) # 800045da <fileclose>
    fileclose(wf);
    80005c34:	fc843503          	ld	a0,-56(s0)
    80005c38:	fffff097          	auipc	ra,0xfffff
    80005c3c:	9a2080e7          	jalr	-1630(ra) # 800045da <fileclose>
    return -1;
    80005c40:	57fd                	li	a5,-1
}
    80005c42:	853e                	mv	a0,a5
    80005c44:	70e2                	ld	ra,56(sp)
    80005c46:	7442                	ld	s0,48(sp)
    80005c48:	74a2                	ld	s1,40(sp)
    80005c4a:	6121                	addi	sp,sp,64
    80005c4c:	8082                	ret

0000000080005c4e <sys_crash>:

// system call to test crashes
uint64
sys_crash(void)
{
    80005c4e:	7171                	addi	sp,sp,-176
    80005c50:	f506                	sd	ra,168(sp)
    80005c52:	f122                	sd	s0,160(sp)
    80005c54:	ed26                	sd	s1,152(sp)
    80005c56:	1900                	addi	s0,sp,176
  char path[MAXPATH];
  struct inode *ip;
  int crash;
  
  if(argstr(0, path, MAXPATH) < 0 || argint(1, &crash) < 0)
    80005c58:	08000613          	li	a2,128
    80005c5c:	f6040593          	addi	a1,s0,-160
    80005c60:	4501                	li	a0,0
    80005c62:	ffffd097          	auipc	ra,0xffffd
    80005c66:	d02080e7          	jalr	-766(ra) # 80002964 <argstr>
    return -1;
    80005c6a:	57fd                	li	a5,-1
  if(argstr(0, path, MAXPATH) < 0 || argint(1, &crash) < 0)
    80005c6c:	04054363          	bltz	a0,80005cb2 <sys_crash+0x64>
    80005c70:	f5c40593          	addi	a1,s0,-164
    80005c74:	4505                	li	a0,1
    80005c76:	ffffd097          	auipc	ra,0xffffd
    80005c7a:	caa080e7          	jalr	-854(ra) # 80002920 <argint>
    return -1;
    80005c7e:	57fd                	li	a5,-1
  if(argstr(0, path, MAXPATH) < 0 || argint(1, &crash) < 0)
    80005c80:	02054963          	bltz	a0,80005cb2 <sys_crash+0x64>
  ip = create(path, T_FILE, 0, 0);
    80005c84:	4681                	li	a3,0
    80005c86:	4601                	li	a2,0
    80005c88:	4589                	li	a1,2
    80005c8a:	f6040513          	addi	a0,s0,-160
    80005c8e:	fffff097          	auipc	ra,0xfffff
    80005c92:	41e080e7          	jalr	1054(ra) # 800050ac <create>
    80005c96:	84aa                	mv	s1,a0
  if(ip == 0){
    80005c98:	c11d                	beqz	a0,80005cbe <sys_crash+0x70>
    return -1;
  }
  iunlockput(ip);
    80005c9a:	ffffe097          	auipc	ra,0xffffe
    80005c9e:	a76080e7          	jalr	-1418(ra) # 80003710 <iunlockput>
  crash_op(ip->dev, crash);
    80005ca2:	f5c42583          	lw	a1,-164(s0)
    80005ca6:	4088                	lw	a0,0(s1)
    80005ca8:	ffffe097          	auipc	ra,0xffffe
    80005cac:	5f2080e7          	jalr	1522(ra) # 8000429a <crash_op>
  return 0;
    80005cb0:	4781                	li	a5,0
}
    80005cb2:	853e                	mv	a0,a5
    80005cb4:	70aa                	ld	ra,168(sp)
    80005cb6:	740a                	ld	s0,160(sp)
    80005cb8:	64ea                	ld	s1,152(sp)
    80005cba:	614d                	addi	sp,sp,176
    80005cbc:	8082                	ret
    return -1;
    80005cbe:	57fd                	li	a5,-1
    80005cc0:	bfcd                	j	80005cb2 <sys_crash+0x64>
	...

0000000080005cd0 <kernelvec>:
    80005cd0:	7111                	addi	sp,sp,-256
    80005cd2:	e006                	sd	ra,0(sp)
    80005cd4:	e40a                	sd	sp,8(sp)
    80005cd6:	e80e                	sd	gp,16(sp)
    80005cd8:	ec12                	sd	tp,24(sp)
    80005cda:	f016                	sd	t0,32(sp)
    80005cdc:	f41a                	sd	t1,40(sp)
    80005cde:	f81e                	sd	t2,48(sp)
    80005ce0:	fc22                	sd	s0,56(sp)
    80005ce2:	e0a6                	sd	s1,64(sp)
    80005ce4:	e4aa                	sd	a0,72(sp)
    80005ce6:	e8ae                	sd	a1,80(sp)
    80005ce8:	ecb2                	sd	a2,88(sp)
    80005cea:	f0b6                	sd	a3,96(sp)
    80005cec:	f4ba                	sd	a4,104(sp)
    80005cee:	f8be                	sd	a5,112(sp)
    80005cf0:	fcc2                	sd	a6,120(sp)
    80005cf2:	e146                	sd	a7,128(sp)
    80005cf4:	e54a                	sd	s2,136(sp)
    80005cf6:	e94e                	sd	s3,144(sp)
    80005cf8:	ed52                	sd	s4,152(sp)
    80005cfa:	f156                	sd	s5,160(sp)
    80005cfc:	f55a                	sd	s6,168(sp)
    80005cfe:	f95e                	sd	s7,176(sp)
    80005d00:	fd62                	sd	s8,184(sp)
    80005d02:	e1e6                	sd	s9,192(sp)
    80005d04:	e5ea                	sd	s10,200(sp)
    80005d06:	e9ee                	sd	s11,208(sp)
    80005d08:	edf2                	sd	t3,216(sp)
    80005d0a:	f1f6                	sd	t4,224(sp)
    80005d0c:	f5fa                	sd	t5,232(sp)
    80005d0e:	f9fe                	sd	t6,240(sp)
    80005d10:	a3dfc0ef          	jal	ra,8000274c <kerneltrap>
    80005d14:	6082                	ld	ra,0(sp)
    80005d16:	6122                	ld	sp,8(sp)
    80005d18:	61c2                	ld	gp,16(sp)
    80005d1a:	7282                	ld	t0,32(sp)
    80005d1c:	7322                	ld	t1,40(sp)
    80005d1e:	73c2                	ld	t2,48(sp)
    80005d20:	7462                	ld	s0,56(sp)
    80005d22:	6486                	ld	s1,64(sp)
    80005d24:	6526                	ld	a0,72(sp)
    80005d26:	65c6                	ld	a1,80(sp)
    80005d28:	6666                	ld	a2,88(sp)
    80005d2a:	7686                	ld	a3,96(sp)
    80005d2c:	7726                	ld	a4,104(sp)
    80005d2e:	77c6                	ld	a5,112(sp)
    80005d30:	7866                	ld	a6,120(sp)
    80005d32:	688a                	ld	a7,128(sp)
    80005d34:	692a                	ld	s2,136(sp)
    80005d36:	69ca                	ld	s3,144(sp)
    80005d38:	6a6a                	ld	s4,152(sp)
    80005d3a:	7a8a                	ld	s5,160(sp)
    80005d3c:	7b2a                	ld	s6,168(sp)
    80005d3e:	7bca                	ld	s7,176(sp)
    80005d40:	7c6a                	ld	s8,184(sp)
    80005d42:	6c8e                	ld	s9,192(sp)
    80005d44:	6d2e                	ld	s10,200(sp)
    80005d46:	6dce                	ld	s11,208(sp)
    80005d48:	6e6e                	ld	t3,216(sp)
    80005d4a:	7e8e                	ld	t4,224(sp)
    80005d4c:	7f2e                	ld	t5,232(sp)
    80005d4e:	7fce                	ld	t6,240(sp)
    80005d50:	6111                	addi	sp,sp,256
    80005d52:	10200073          	sret
    80005d56:	00000013          	nop
    80005d5a:	00000013          	nop
    80005d5e:	0001                	nop

0000000080005d60 <timervec>:
    80005d60:	34051573          	csrrw	a0,mscratch,a0
    80005d64:	e10c                	sd	a1,0(a0)
    80005d66:	e510                	sd	a2,8(a0)
    80005d68:	e914                	sd	a3,16(a0)
    80005d6a:	710c                	ld	a1,32(a0)
    80005d6c:	7510                	ld	a2,40(a0)
    80005d6e:	6194                	ld	a3,0(a1)
    80005d70:	96b2                	add	a3,a3,a2
    80005d72:	e194                	sd	a3,0(a1)
    80005d74:	4589                	li	a1,2
    80005d76:	14459073          	csrw	sip,a1
    80005d7a:	6914                	ld	a3,16(a0)
    80005d7c:	6510                	ld	a2,8(a0)
    80005d7e:	610c                	ld	a1,0(a0)
    80005d80:	34051573          	csrrw	a0,mscratch,a0
    80005d84:	30200073          	mret
	...

0000000080005d8a <plicinit>:
// the riscv Platform Level Interrupt Controller (PLIC).
//

void
plicinit(void)
{
    80005d8a:	1141                	addi	sp,sp,-16
    80005d8c:	e422                	sd	s0,8(sp)
    80005d8e:	0800                	addi	s0,sp,16
  // set desired IRQ priorities non-zero (otherwise disabled).
  *(uint32*)(PLIC + UART0_IRQ*4) = 1;
    80005d90:	0c0007b7          	lui	a5,0xc000
    80005d94:	4705                	li	a4,1
    80005d96:	d798                	sw	a4,40(a5)
  *(uint32*)(PLIC + VIRTIO0_IRQ*4) = 1;
    80005d98:	c3d8                	sw	a4,4(a5)
}
    80005d9a:	6422                	ld	s0,8(sp)
    80005d9c:	0141                	addi	sp,sp,16
    80005d9e:	8082                	ret

0000000080005da0 <plicinithart>:

void
plicinithart(void)
{
    80005da0:	1141                	addi	sp,sp,-16
    80005da2:	e406                	sd	ra,8(sp)
    80005da4:	e022                	sd	s0,0(sp)
    80005da6:	0800                	addi	s0,sp,16
  int hart = cpuid();
    80005da8:	ffffc097          	auipc	ra,0xffffc
    80005dac:	aca080e7          	jalr	-1334(ra) # 80001872 <cpuid>
  
  // set uart's enable bit for this hart's S-mode. 
  *(uint32*)PLIC_SENABLE(hart)= (1 << UART0_IRQ) | (1 << VIRTIO0_IRQ);
    80005db0:	0085171b          	slliw	a4,a0,0x8
    80005db4:	0c0027b7          	lui	a5,0xc002
    80005db8:	97ba                	add	a5,a5,a4
    80005dba:	40200713          	li	a4,1026
    80005dbe:	08e7a023          	sw	a4,128(a5) # c002080 <_entry-0x73ffdf80>

  // set this hart's S-mode priority threshold to 0.
  *(uint32*)PLIC_SPRIORITY(hart) = 0;
    80005dc2:	00d5151b          	slliw	a0,a0,0xd
    80005dc6:	0c2017b7          	lui	a5,0xc201
    80005dca:	953e                	add	a0,a0,a5
    80005dcc:	00052023          	sw	zero,0(a0)
}
    80005dd0:	60a2                	ld	ra,8(sp)
    80005dd2:	6402                	ld	s0,0(sp)
    80005dd4:	0141                	addi	sp,sp,16
    80005dd6:	8082                	ret

0000000080005dd8 <plic_pending>:

// return a bitmap of which IRQs are waiting
// to be served.
uint64
plic_pending(void)
{
    80005dd8:	1141                	addi	sp,sp,-16
    80005dda:	e422                	sd	s0,8(sp)
    80005ddc:	0800                	addi	s0,sp,16
  //mask = *(uint32*)(PLIC + 0x1000);
  //mask |= (uint64)*(uint32*)(PLIC + 0x1004) << 32;
  mask = *(uint64*)PLIC_PENDING;

  return mask;
}
    80005dde:	0c0017b7          	lui	a5,0xc001
    80005de2:	6388                	ld	a0,0(a5)
    80005de4:	6422                	ld	s0,8(sp)
    80005de6:	0141                	addi	sp,sp,16
    80005de8:	8082                	ret

0000000080005dea <plic_claim>:

// ask the PLIC what interrupt we should serve.
int
plic_claim(void)
{
    80005dea:	1141                	addi	sp,sp,-16
    80005dec:	e406                	sd	ra,8(sp)
    80005dee:	e022                	sd	s0,0(sp)
    80005df0:	0800                	addi	s0,sp,16
  int hart = cpuid();
    80005df2:	ffffc097          	auipc	ra,0xffffc
    80005df6:	a80080e7          	jalr	-1408(ra) # 80001872 <cpuid>
  //int irq = *(uint32*)(PLIC + 0x201004);
  int irq = *(uint32*)PLIC_SCLAIM(hart);
    80005dfa:	00d5151b          	slliw	a0,a0,0xd
    80005dfe:	0c2017b7          	lui	a5,0xc201
    80005e02:	97aa                	add	a5,a5,a0
  return irq;
}
    80005e04:	43c8                	lw	a0,4(a5)
    80005e06:	60a2                	ld	ra,8(sp)
    80005e08:	6402                	ld	s0,0(sp)
    80005e0a:	0141                	addi	sp,sp,16
    80005e0c:	8082                	ret

0000000080005e0e <plic_complete>:

// tell the PLIC we've served this IRQ.
void
plic_complete(int irq)
{
    80005e0e:	1101                	addi	sp,sp,-32
    80005e10:	ec06                	sd	ra,24(sp)
    80005e12:	e822                	sd	s0,16(sp)
    80005e14:	e426                	sd	s1,8(sp)
    80005e16:	1000                	addi	s0,sp,32
    80005e18:	84aa                	mv	s1,a0
  int hart = cpuid();
    80005e1a:	ffffc097          	auipc	ra,0xffffc
    80005e1e:	a58080e7          	jalr	-1448(ra) # 80001872 <cpuid>
  //*(uint32*)(PLIC + 0x201004) = irq;
  *(uint32*)PLIC_SCLAIM(hart) = irq;
    80005e22:	00d5151b          	slliw	a0,a0,0xd
    80005e26:	0c2017b7          	lui	a5,0xc201
    80005e2a:	97aa                	add	a5,a5,a0
    80005e2c:	c3c4                	sw	s1,4(a5)
}
    80005e2e:	60e2                	ld	ra,24(sp)
    80005e30:	6442                	ld	s0,16(sp)
    80005e32:	64a2                	ld	s1,8(sp)
    80005e34:	6105                	addi	sp,sp,32
    80005e36:	8082                	ret

0000000080005e38 <free_desc>:
}

// mark a descriptor as free.
static void
free_desc(int n, int i)
{
    80005e38:	1141                	addi	sp,sp,-16
    80005e3a:	e406                	sd	ra,8(sp)
    80005e3c:	e022                	sd	s0,0(sp)
    80005e3e:	0800                	addi	s0,sp,16
  if(i >= NUM)
    80005e40:	479d                	li	a5,7
    80005e42:	06b7c863          	blt	a5,a1,80005eb2 <free_desc+0x7a>
    panic("virtio_disk_intr 1");
  if(disk[n].free[i])
    80005e46:	00151713          	slli	a4,a0,0x1
    80005e4a:	972a                	add	a4,a4,a0
    80005e4c:	00c71693          	slli	a3,a4,0xc
    80005e50:	0001d717          	auipc	a4,0x1d
    80005e54:	1b070713          	addi	a4,a4,432 # 80023000 <disk>
    80005e58:	9736                	add	a4,a4,a3
    80005e5a:	972e                	add	a4,a4,a1
    80005e5c:	6789                	lui	a5,0x2
    80005e5e:	973e                	add	a4,a4,a5
    80005e60:	01874783          	lbu	a5,24(a4)
    80005e64:	efb9                	bnez	a5,80005ec2 <free_desc+0x8a>
    panic("virtio_disk_intr 2");
  disk[n].desc[i].addr = 0;
    80005e66:	0001d817          	auipc	a6,0x1d
    80005e6a:	19a80813          	addi	a6,a6,410 # 80023000 <disk>
    80005e6e:	00151713          	slli	a4,a0,0x1
    80005e72:	00a707b3          	add	a5,a4,a0
    80005e76:	07b2                	slli	a5,a5,0xc
    80005e78:	97c2                	add	a5,a5,a6
    80005e7a:	6689                	lui	a3,0x2
    80005e7c:	00f68633          	add	a2,a3,a5
    80005e80:	6210                	ld	a2,0(a2)
    80005e82:	00459893          	slli	a7,a1,0x4
    80005e86:	9646                	add	a2,a2,a7
    80005e88:	00063023          	sd	zero,0(a2) # 1000 <_entry-0x7ffff000>
  disk[n].free[i] = 1;
    80005e8c:	97ae                	add	a5,a5,a1
    80005e8e:	97b6                	add	a5,a5,a3
    80005e90:	4605                	li	a2,1
    80005e92:	00c78c23          	sb	a2,24(a5) # 2018 <_entry-0x7fffdfe8>
  wakeup(&disk[n].free[0]);
    80005e96:	972a                	add	a4,a4,a0
    80005e98:	0732                	slli	a4,a4,0xc
    80005e9a:	06e1                	addi	a3,a3,24
    80005e9c:	9736                	add	a4,a4,a3
    80005e9e:	00e80533          	add	a0,a6,a4
    80005ea2:	ffffc097          	auipc	ra,0xffffc
    80005ea6:	356080e7          	jalr	854(ra) # 800021f8 <wakeup>
}
    80005eaa:	60a2                	ld	ra,8(sp)
    80005eac:	6402                	ld	s0,0(sp)
    80005eae:	0141                	addi	sp,sp,16
    80005eb0:	8082                	ret
    panic("virtio_disk_intr 1");
    80005eb2:	00002517          	auipc	a0,0x2
    80005eb6:	94e50513          	addi	a0,a0,-1714 # 80007800 <userret+0x770>
    80005eba:	ffffa097          	auipc	ra,0xffffa
    80005ebe:	6c4080e7          	jalr	1732(ra) # 8000057e <panic>
    panic("virtio_disk_intr 2");
    80005ec2:	00002517          	auipc	a0,0x2
    80005ec6:	95650513          	addi	a0,a0,-1706 # 80007818 <userret+0x788>
    80005eca:	ffffa097          	auipc	ra,0xffffa
    80005ece:	6b4080e7          	jalr	1716(ra) # 8000057e <panic>

0000000080005ed2 <virtio_disk_init>:
  __sync_synchronize();
    80005ed2:	0ff0000f          	fence
  if(disk[n].init)
    80005ed6:	00151793          	slli	a5,a0,0x1
    80005eda:	97aa                	add	a5,a5,a0
    80005edc:	07b2                	slli	a5,a5,0xc
    80005ede:	0001d717          	auipc	a4,0x1d
    80005ee2:	12270713          	addi	a4,a4,290 # 80023000 <disk>
    80005ee6:	973e                	add	a4,a4,a5
    80005ee8:	6789                	lui	a5,0x2
    80005eea:	97ba                	add	a5,a5,a4
    80005eec:	0a87a783          	lw	a5,168(a5) # 20a8 <_entry-0x7fffdf58>
    80005ef0:	c391                	beqz	a5,80005ef4 <virtio_disk_init+0x22>
    80005ef2:	8082                	ret
{
    80005ef4:	7139                	addi	sp,sp,-64
    80005ef6:	fc06                	sd	ra,56(sp)
    80005ef8:	f822                	sd	s0,48(sp)
    80005efa:	f426                	sd	s1,40(sp)
    80005efc:	f04a                	sd	s2,32(sp)
    80005efe:	ec4e                	sd	s3,24(sp)
    80005f00:	e852                	sd	s4,16(sp)
    80005f02:	e456                	sd	s5,8(sp)
    80005f04:	0080                	addi	s0,sp,64
    80005f06:	892a                	mv	s2,a0
  printf("virtio disk init %d\n", n);
    80005f08:	85aa                	mv	a1,a0
    80005f0a:	00002517          	auipc	a0,0x2
    80005f0e:	92650513          	addi	a0,a0,-1754 # 80007830 <userret+0x7a0>
    80005f12:	ffffa097          	auipc	ra,0xffffa
    80005f16:	6b6080e7          	jalr	1718(ra) # 800005c8 <printf>
  initlock(&disk[n].vdisk_lock, "virtio_disk");
    80005f1a:	00191993          	slli	s3,s2,0x1
    80005f1e:	99ca                	add	s3,s3,s2
    80005f20:	09b2                	slli	s3,s3,0xc
    80005f22:	6789                	lui	a5,0x2
    80005f24:	0b078793          	addi	a5,a5,176 # 20b0 <_entry-0x7fffdf50>
    80005f28:	97ce                	add	a5,a5,s3
    80005f2a:	00002597          	auipc	a1,0x2
    80005f2e:	91e58593          	addi	a1,a1,-1762 # 80007848 <userret+0x7b8>
    80005f32:	0001d517          	auipc	a0,0x1d
    80005f36:	0ce50513          	addi	a0,a0,206 # 80023000 <disk>
    80005f3a:	953e                	add	a0,a0,a5
    80005f3c:	ffffb097          	auipc	ra,0xffffb
    80005f40:	ab6080e7          	jalr	-1354(ra) # 800009f2 <initlock>
  if(*R(n, VIRTIO_MMIO_MAGIC_VALUE) != 0x74726976 ||
    80005f44:	0019049b          	addiw	s1,s2,1
    80005f48:	00c4949b          	slliw	s1,s1,0xc
    80005f4c:	100007b7          	lui	a5,0x10000
    80005f50:	97a6                	add	a5,a5,s1
    80005f52:	4398                	lw	a4,0(a5)
    80005f54:	2701                	sext.w	a4,a4
    80005f56:	747277b7          	lui	a5,0x74727
    80005f5a:	97678793          	addi	a5,a5,-1674 # 74726976 <_entry-0xb8d968a>
    80005f5e:	12f71763          	bne	a4,a5,8000608c <virtio_disk_init+0x1ba>
     *R(n, VIRTIO_MMIO_VERSION) != 1 ||
    80005f62:	100007b7          	lui	a5,0x10000
    80005f66:	0791                	addi	a5,a5,4
    80005f68:	97a6                	add	a5,a5,s1
    80005f6a:	439c                	lw	a5,0(a5)
    80005f6c:	2781                	sext.w	a5,a5
  if(*R(n, VIRTIO_MMIO_MAGIC_VALUE) != 0x74726976 ||
    80005f6e:	4705                	li	a4,1
    80005f70:	10e79e63          	bne	a5,a4,8000608c <virtio_disk_init+0x1ba>
     *R(n, VIRTIO_MMIO_DEVICE_ID) != 2 ||
    80005f74:	100007b7          	lui	a5,0x10000
    80005f78:	07a1                	addi	a5,a5,8
    80005f7a:	97a6                	add	a5,a5,s1
    80005f7c:	439c                	lw	a5,0(a5)
    80005f7e:	2781                	sext.w	a5,a5
     *R(n, VIRTIO_MMIO_VERSION) != 1 ||
    80005f80:	4709                	li	a4,2
    80005f82:	10e79563          	bne	a5,a4,8000608c <virtio_disk_init+0x1ba>
     *R(n, VIRTIO_MMIO_VENDOR_ID) != 0x554d4551){
    80005f86:	100007b7          	lui	a5,0x10000
    80005f8a:	07b1                	addi	a5,a5,12
    80005f8c:	97a6                	add	a5,a5,s1
    80005f8e:	4398                	lw	a4,0(a5)
    80005f90:	2701                	sext.w	a4,a4
     *R(n, VIRTIO_MMIO_DEVICE_ID) != 2 ||
    80005f92:	554d47b7          	lui	a5,0x554d4
    80005f96:	55178793          	addi	a5,a5,1361 # 554d4551 <_entry-0x2ab2baaf>
    80005f9a:	0ef71963          	bne	a4,a5,8000608c <virtio_disk_init+0x1ba>
  *R(n, VIRTIO_MMIO_STATUS) = status;
    80005f9e:	100007b7          	lui	a5,0x10000
    80005fa2:	07078693          	addi	a3,a5,112 # 10000070 <_entry-0x6fffff90>
    80005fa6:	96a6                	add	a3,a3,s1
    80005fa8:	4705                	li	a4,1
    80005faa:	c298                	sw	a4,0(a3)
  *R(n, VIRTIO_MMIO_STATUS) = status;
    80005fac:	470d                	li	a4,3
    80005fae:	c298                	sw	a4,0(a3)
  uint64 features = *R(n, VIRTIO_MMIO_DEVICE_FEATURES);
    80005fb0:	01078713          	addi	a4,a5,16
    80005fb4:	9726                	add	a4,a4,s1
    80005fb6:	430c                	lw	a1,0(a4)
  *R(n, VIRTIO_MMIO_DRIVER_FEATURES) = features;
    80005fb8:	02078613          	addi	a2,a5,32
    80005fbc:	9626                	add	a2,a2,s1
  features &= ~(1 << VIRTIO_RING_F_INDIRECT_DESC);
    80005fbe:	c7ffe737          	lui	a4,0xc7ffe
    80005fc2:	75f70713          	addi	a4,a4,1887 # ffffffffc7ffe75f <ticks+0xffffffff47fd5737>
    80005fc6:	8f6d                	and	a4,a4,a1
  *R(n, VIRTIO_MMIO_DRIVER_FEATURES) = features;
    80005fc8:	2701                	sext.w	a4,a4
    80005fca:	c218                	sw	a4,0(a2)
  *R(n, VIRTIO_MMIO_STATUS) = status;
    80005fcc:	472d                	li	a4,11
    80005fce:	c298                	sw	a4,0(a3)
  *R(n, VIRTIO_MMIO_STATUS) = status;
    80005fd0:	473d                	li	a4,15
    80005fd2:	c298                	sw	a4,0(a3)
  *R(n, VIRTIO_MMIO_GUEST_PAGE_SIZE) = PGSIZE;
    80005fd4:	02878713          	addi	a4,a5,40
    80005fd8:	9726                	add	a4,a4,s1
    80005fda:	6685                	lui	a3,0x1
    80005fdc:	c314                	sw	a3,0(a4)
  *R(n, VIRTIO_MMIO_QUEUE_SEL) = 0;
    80005fde:	03078713          	addi	a4,a5,48
    80005fe2:	9726                	add	a4,a4,s1
    80005fe4:	00072023          	sw	zero,0(a4)
  uint32 max = *R(n, VIRTIO_MMIO_QUEUE_NUM_MAX);
    80005fe8:	03478793          	addi	a5,a5,52
    80005fec:	97a6                	add	a5,a5,s1
    80005fee:	439c                	lw	a5,0(a5)
    80005ff0:	2781                	sext.w	a5,a5
  if(max == 0)
    80005ff2:	c7cd                	beqz	a5,8000609c <virtio_disk_init+0x1ca>
  if(max < NUM)
    80005ff4:	471d                	li	a4,7
    80005ff6:	0af77b63          	bleu	a5,a4,800060ac <virtio_disk_init+0x1da>
  *R(n, VIRTIO_MMIO_QUEUE_NUM) = NUM;
    80005ffa:	10000ab7          	lui	s5,0x10000
    80005ffe:	038a8793          	addi	a5,s5,56 # 10000038 <_entry-0x6fffffc8>
    80006002:	97a6                	add	a5,a5,s1
    80006004:	4721                	li	a4,8
    80006006:	c398                	sw	a4,0(a5)
  memset(disk[n].pages, 0, sizeof(disk[n].pages));
    80006008:	0001da17          	auipc	s4,0x1d
    8000600c:	ff8a0a13          	addi	s4,s4,-8 # 80023000 <disk>
    80006010:	99d2                	add	s3,s3,s4
    80006012:	6609                	lui	a2,0x2
    80006014:	4581                	li	a1,0
    80006016:	854e                	mv	a0,s3
    80006018:	ffffb097          	auipc	ra,0xffffb
    8000601c:	bae080e7          	jalr	-1106(ra) # 80000bc6 <memset>
  *R(n, VIRTIO_MMIO_QUEUE_PFN) = ((uint64)disk[n].pages) >> PGSHIFT;
    80006020:	040a8a93          	addi	s5,s5,64
    80006024:	94d6                	add	s1,s1,s5
    80006026:	00c9d793          	srli	a5,s3,0xc
    8000602a:	2781                	sext.w	a5,a5
    8000602c:	c09c                	sw	a5,0(s1)
  disk[n].desc = (struct VRingDesc *) disk[n].pages;
    8000602e:	00191513          	slli	a0,s2,0x1
    80006032:	012507b3          	add	a5,a0,s2
    80006036:	07b2                	slli	a5,a5,0xc
    80006038:	97d2                	add	a5,a5,s4
    8000603a:	6689                	lui	a3,0x2
    8000603c:	97b6                	add	a5,a5,a3
    8000603e:	0137b023          	sd	s3,0(a5)
  disk[n].avail = (uint16*)(((char*)disk[n].desc) + NUM*sizeof(struct VRingDesc));
    80006042:	08098713          	addi	a4,s3,128
    80006046:	e798                	sd	a4,8(a5)
  disk[n].used = (struct UsedArea *) (disk[n].pages + PGSIZE);
    80006048:	6705                	lui	a4,0x1
    8000604a:	99ba                	add	s3,s3,a4
    8000604c:	0137b823          	sd	s3,16(a5)
    disk[n].free[i] = 1;
    80006050:	4705                	li	a4,1
    80006052:	00e78c23          	sb	a4,24(a5)
    80006056:	00e78ca3          	sb	a4,25(a5)
    8000605a:	00e78d23          	sb	a4,26(a5)
    8000605e:	00e78da3          	sb	a4,27(a5)
    80006062:	00e78e23          	sb	a4,28(a5)
    80006066:	00e78ea3          	sb	a4,29(a5)
    8000606a:	00e78f23          	sb	a4,30(a5)
    8000606e:	00e78fa3          	sb	a4,31(a5)
  disk[n].init = 1;
    80006072:	853e                	mv	a0,a5
    80006074:	4785                	li	a5,1
    80006076:	0af52423          	sw	a5,168(a0)
}
    8000607a:	70e2                	ld	ra,56(sp)
    8000607c:	7442                	ld	s0,48(sp)
    8000607e:	74a2                	ld	s1,40(sp)
    80006080:	7902                	ld	s2,32(sp)
    80006082:	69e2                	ld	s3,24(sp)
    80006084:	6a42                	ld	s4,16(sp)
    80006086:	6aa2                	ld	s5,8(sp)
    80006088:	6121                	addi	sp,sp,64
    8000608a:	8082                	ret
    panic("could not find virtio disk");
    8000608c:	00001517          	auipc	a0,0x1
    80006090:	7cc50513          	addi	a0,a0,1996 # 80007858 <userret+0x7c8>
    80006094:	ffffa097          	auipc	ra,0xffffa
    80006098:	4ea080e7          	jalr	1258(ra) # 8000057e <panic>
    panic("virtio disk has no queue 0");
    8000609c:	00001517          	auipc	a0,0x1
    800060a0:	7dc50513          	addi	a0,a0,2012 # 80007878 <userret+0x7e8>
    800060a4:	ffffa097          	auipc	ra,0xffffa
    800060a8:	4da080e7          	jalr	1242(ra) # 8000057e <panic>
    panic("virtio disk max queue too short");
    800060ac:	00001517          	auipc	a0,0x1
    800060b0:	7ec50513          	addi	a0,a0,2028 # 80007898 <userret+0x808>
    800060b4:	ffffa097          	auipc	ra,0xffffa
    800060b8:	4ca080e7          	jalr	1226(ra) # 8000057e <panic>

00000000800060bc <virtio_disk_rw>:
  return 0;
}

void
virtio_disk_rw(int n, struct buf *b, int write)
{
    800060bc:	7175                	addi	sp,sp,-144
    800060be:	e506                	sd	ra,136(sp)
    800060c0:	e122                	sd	s0,128(sp)
    800060c2:	fca6                	sd	s1,120(sp)
    800060c4:	f8ca                	sd	s2,112(sp)
    800060c6:	f4ce                	sd	s3,104(sp)
    800060c8:	f0d2                	sd	s4,96(sp)
    800060ca:	ecd6                	sd	s5,88(sp)
    800060cc:	e8da                	sd	s6,80(sp)
    800060ce:	e4de                	sd	s7,72(sp)
    800060d0:	e0e2                	sd	s8,64(sp)
    800060d2:	fc66                	sd	s9,56(sp)
    800060d4:	f86a                	sd	s10,48(sp)
    800060d6:	f46e                	sd	s11,40(sp)
    800060d8:	0900                	addi	s0,sp,144
    800060da:	892a                	mv	s2,a0
    800060dc:	8a2e                	mv	s4,a1
    800060de:	8db2                	mv	s11,a2
  uint64 sector = b->blockno * (BSIZE / 512);
    800060e0:	00c5ad03          	lw	s10,12(a1)
    800060e4:	001d1d1b          	slliw	s10,s10,0x1
    800060e8:	1d02                	slli	s10,s10,0x20
    800060ea:	020d5d13          	srli	s10,s10,0x20

  acquire(&disk[n].vdisk_lock);
    800060ee:	00151493          	slli	s1,a0,0x1
    800060f2:	94aa                	add	s1,s1,a0
    800060f4:	04b2                	slli	s1,s1,0xc
    800060f6:	6a89                	lui	s5,0x2
    800060f8:	0b0a8993          	addi	s3,s5,176 # 20b0 <_entry-0x7fffdf50>
    800060fc:	99a6                	add	s3,s3,s1
    800060fe:	0001dc17          	auipc	s8,0x1d
    80006102:	f02c0c13          	addi	s8,s8,-254 # 80023000 <disk>
    80006106:	99e2                	add	s3,s3,s8
    80006108:	854e                	mv	a0,s3
    8000610a:	ffffb097          	auipc	ra,0xffffb
    8000610e:	9f6080e7          	jalr	-1546(ra) # 80000b00 <acquire>
  int idx[3];
  while(1){
    if(alloc3_desc(n, idx) == 0) {
      break;
    }
    sleep(&disk[n].free[0], &disk[n].vdisk_lock);
    80006112:	018a8b93          	addi	s7,s5,24
    80006116:	9ba6                	add	s7,s7,s1
    80006118:	9be2                	add	s7,s7,s8
    8000611a:	0ae5                	addi	s5,s5,25
    8000611c:	94d6                	add	s1,s1,s5
    8000611e:	01848ab3          	add	s5,s1,s8
    if(disk[n].free[i]){
    80006122:	00191b13          	slli	s6,s2,0x1
    80006126:	9b4a                	add	s6,s6,s2
    80006128:	00cb1793          	slli	a5,s6,0xc
    8000612c:	00fc0b33          	add	s6,s8,a5
    80006130:	6c89                	lui	s9,0x2
    80006132:	016c8c33          	add	s8,s9,s6
    80006136:	a049                	j	800061b8 <virtio_disk_rw+0xfc>
      disk[n].free[i] = 0;
    80006138:	00fb06b3          	add	a3,s6,a5
    8000613c:	96e6                	add	a3,a3,s9
    8000613e:	00068c23          	sb	zero,24(a3) # 2018 <_entry-0x7fffdfe8>
    idx[i] = alloc_desc(n);
    80006142:	c21c                	sw	a5,0(a2)
    if(idx[i] < 0){
    80006144:	0207c763          	bltz	a5,80006172 <virtio_disk_rw+0xb6>
  for(int i = 0; i < 3; i++){
    80006148:	2485                	addiw	s1,s1,1
    8000614a:	0711                	addi	a4,a4,4
    8000614c:	28b48063          	beq	s1,a1,800063cc <virtio_disk_rw+0x310>
    idx[i] = alloc_desc(n);
    80006150:	863a                	mv	a2,a4
    if(disk[n].free[i]){
    80006152:	018c4783          	lbu	a5,24(s8)
    80006156:	28079063          	bnez	a5,800063d6 <virtio_disk_rw+0x31a>
    8000615a:	86d6                	mv	a3,s5
  for(int i = 0; i < NUM; i++){
    8000615c:	87c2                	mv	a5,a6
    if(disk[n].free[i]){
    8000615e:	0006c883          	lbu	a7,0(a3)
    80006162:	fc089be3          	bnez	a7,80006138 <virtio_disk_rw+0x7c>
  for(int i = 0; i < NUM; i++){
    80006166:	2785                	addiw	a5,a5,1
    80006168:	0685                	addi	a3,a3,1
    8000616a:	fea79ae3          	bne	a5,a0,8000615e <virtio_disk_rw+0xa2>
    idx[i] = alloc_desc(n);
    8000616e:	57fd                	li	a5,-1
    80006170:	c21c                	sw	a5,0(a2)
      for(int j = 0; j < i; j++)
    80006172:	02905d63          	blez	s1,800061ac <virtio_disk_rw+0xf0>
        free_desc(n, idx[j]);
    80006176:	f8042583          	lw	a1,-128(s0)
    8000617a:	854a                	mv	a0,s2
    8000617c:	00000097          	auipc	ra,0x0
    80006180:	cbc080e7          	jalr	-836(ra) # 80005e38 <free_desc>
      for(int j = 0; j < i; j++)
    80006184:	4785                	li	a5,1
    80006186:	0297d363          	ble	s1,a5,800061ac <virtio_disk_rw+0xf0>
        free_desc(n, idx[j]);
    8000618a:	f8442583          	lw	a1,-124(s0)
    8000618e:	854a                	mv	a0,s2
    80006190:	00000097          	auipc	ra,0x0
    80006194:	ca8080e7          	jalr	-856(ra) # 80005e38 <free_desc>
      for(int j = 0; j < i; j++)
    80006198:	4789                	li	a5,2
    8000619a:	0097d963          	ble	s1,a5,800061ac <virtio_disk_rw+0xf0>
        free_desc(n, idx[j]);
    8000619e:	f8842583          	lw	a1,-120(s0)
    800061a2:	854a                	mv	a0,s2
    800061a4:	00000097          	auipc	ra,0x0
    800061a8:	c94080e7          	jalr	-876(ra) # 80005e38 <free_desc>
    sleep(&disk[n].free[0], &disk[n].vdisk_lock);
    800061ac:	85ce                	mv	a1,s3
    800061ae:	855e                	mv	a0,s7
    800061b0:	ffffc097          	auipc	ra,0xffffc
    800061b4:	efc080e7          	jalr	-260(ra) # 800020ac <sleep>
  for(int i = 0; i < 3; i++){
    800061b8:	f8040713          	addi	a4,s0,-128
    800061bc:	4481                	li	s1,0
  for(int i = 0; i < NUM; i++){
    800061be:	4805                	li	a6,1
    800061c0:	4521                	li	a0,8
  for(int i = 0; i < 3; i++){
    800061c2:	458d                	li	a1,3
    800061c4:	b771                	j	80006150 <virtio_disk_rw+0x94>
    uint32 reserved;
    uint64 sector;
  } buf0;

  if(write)
    buf0.type = VIRTIO_BLK_T_OUT; // write the disk
    800061c6:	4785                	li	a5,1
    800061c8:	f6f42823          	sw	a5,-144(s0)
  else
    buf0.type = VIRTIO_BLK_T_IN; // read the disk
  buf0.reserved = 0;
    800061cc:	f6042a23          	sw	zero,-140(s0)
  buf0.sector = sector;
    800061d0:	f7a43c23          	sd	s10,-136(s0)

  // buf0 is on a kernel stack, which is not direct mapped,
  // thus the call to kvmpa().
  disk[n].desc[idx[0]].addr = (uint64) kvmpa((uint64) &buf0);
    800061d4:	f8042483          	lw	s1,-128(s0)
    800061d8:	00449b13          	slli	s6,s1,0x4
    800061dc:	00191793          	slli	a5,s2,0x1
    800061e0:	97ca                	add	a5,a5,s2
    800061e2:	07b2                	slli	a5,a5,0xc
    800061e4:	0001da97          	auipc	s5,0x1d
    800061e8:	e1ca8a93          	addi	s5,s5,-484 # 80023000 <disk>
    800061ec:	97d6                	add	a5,a5,s5
    800061ee:	6a89                	lui	s5,0x2
    800061f0:	9abe                	add	s5,s5,a5
    800061f2:	000abb83          	ld	s7,0(s5) # 2000 <_entry-0x7fffe000>
    800061f6:	9bda                	add	s7,s7,s6
    800061f8:	f7040513          	addi	a0,s0,-144
    800061fc:	ffffb097          	auipc	ra,0xffffb
    80006200:	e22080e7          	jalr	-478(ra) # 8000101e <kvmpa>
    80006204:	00abb023          	sd	a0,0(s7)
  disk[n].desc[idx[0]].len = sizeof(buf0);
    80006208:	000ab783          	ld	a5,0(s5)
    8000620c:	97da                	add	a5,a5,s6
    8000620e:	4741                	li	a4,16
    80006210:	c798                	sw	a4,8(a5)
  disk[n].desc[idx[0]].flags = VRING_DESC_F_NEXT;
    80006212:	000ab783          	ld	a5,0(s5)
    80006216:	97da                	add	a5,a5,s6
    80006218:	4705                	li	a4,1
    8000621a:	00e79623          	sh	a4,12(a5)
  disk[n].desc[idx[0]].next = idx[1];
    8000621e:	f8442603          	lw	a2,-124(s0)
    80006222:	000ab783          	ld	a5,0(s5)
    80006226:	9b3e                	add	s6,s6,a5
    80006228:	00cb1723          	sh	a2,14(s6)

  disk[n].desc[idx[1]].addr = (uint64) b->data;
    8000622c:	0612                	slli	a2,a2,0x4
    8000622e:	000ab783          	ld	a5,0(s5)
    80006232:	97b2                	add	a5,a5,a2
    80006234:	060a0713          	addi	a4,s4,96
    80006238:	e398                	sd	a4,0(a5)
  disk[n].desc[idx[1]].len = BSIZE;
    8000623a:	000ab783          	ld	a5,0(s5)
    8000623e:	97b2                	add	a5,a5,a2
    80006240:	40000713          	li	a4,1024
    80006244:	c798                	sw	a4,8(a5)
  if(write)
    80006246:	120d8e63          	beqz	s11,80006382 <virtio_disk_rw+0x2c6>
    disk[n].desc[idx[1]].flags = 0; // device reads b->data
    8000624a:	000ab783          	ld	a5,0(s5)
    8000624e:	97b2                	add	a5,a5,a2
    80006250:	00079623          	sh	zero,12(a5)
  else
    disk[n].desc[idx[1]].flags = VRING_DESC_F_WRITE; // device writes b->data
  disk[n].desc[idx[1]].flags |= VRING_DESC_F_NEXT;
    80006254:	0001d517          	auipc	a0,0x1d
    80006258:	dac50513          	addi	a0,a0,-596 # 80023000 <disk>
    8000625c:	00191793          	slli	a5,s2,0x1
    80006260:	012786b3          	add	a3,a5,s2
    80006264:	06b2                	slli	a3,a3,0xc
    80006266:	96aa                	add	a3,a3,a0
    80006268:	6709                	lui	a4,0x2
    8000626a:	96ba                	add	a3,a3,a4
    8000626c:	628c                	ld	a1,0(a3)
    8000626e:	95b2                	add	a1,a1,a2
    80006270:	00c5d703          	lhu	a4,12(a1)
    80006274:	00176713          	ori	a4,a4,1
    80006278:	00e59623          	sh	a4,12(a1)
  disk[n].desc[idx[1]].next = idx[2];
    8000627c:	f8842583          	lw	a1,-120(s0)
    80006280:	6298                	ld	a4,0(a3)
    80006282:	963a                	add	a2,a2,a4
    80006284:	00b61723          	sh	a1,14(a2) # 200e <_entry-0x7fffdff2>

  disk[n].info[idx[0]].status = 0;
    80006288:	97ca                	add	a5,a5,s2
    8000628a:	07a2                	slli	a5,a5,0x8
    8000628c:	97a6                	add	a5,a5,s1
    8000628e:	20078793          	addi	a5,a5,512
    80006292:	0792                	slli	a5,a5,0x4
    80006294:	97aa                	add	a5,a5,a0
    80006296:	02078823          	sb	zero,48(a5)
  disk[n].desc[idx[2]].addr = (uint64) &disk[n].info[idx[0]].status;
    8000629a:	00459613          	slli	a2,a1,0x4
    8000629e:	628c                	ld	a1,0(a3)
    800062a0:	95b2                	add	a1,a1,a2
    800062a2:	00191713          	slli	a4,s2,0x1
    800062a6:	974a                	add	a4,a4,s2
    800062a8:	0722                	slli	a4,a4,0x8
    800062aa:	20348813          	addi	a6,s1,515
    800062ae:	9742                	add	a4,a4,a6
    800062b0:	0712                	slli	a4,a4,0x4
    800062b2:	972a                	add	a4,a4,a0
    800062b4:	e198                	sd	a4,0(a1)
  disk[n].desc[idx[2]].len = 1;
    800062b6:	6298                	ld	a4,0(a3)
    800062b8:	9732                	add	a4,a4,a2
    800062ba:	4585                	li	a1,1
    800062bc:	c70c                	sw	a1,8(a4)
  disk[n].desc[idx[2]].flags = VRING_DESC_F_WRITE; // device writes the status
    800062be:	6298                	ld	a4,0(a3)
    800062c0:	9732                	add	a4,a4,a2
    800062c2:	4509                	li	a0,2
    800062c4:	00a71623          	sh	a0,12(a4) # 200c <_entry-0x7fffdff4>
  disk[n].desc[idx[2]].next = 0;
    800062c8:	6298                	ld	a4,0(a3)
    800062ca:	963a                	add	a2,a2,a4
    800062cc:	00061723          	sh	zero,14(a2)

  // record struct buf for virtio_disk_intr().
  b->disk = 1;
    800062d0:	00ba2223          	sw	a1,4(s4)
  disk[n].info[idx[0]].b = b;
    800062d4:	0347b423          	sd	s4,40(a5)

  // avail[0] is flags
  // avail[1] tells the device how far to look in avail[2...].
  // avail[2...] are desc[] indices the device should process.
  // we only tell device the first index in our chain of descriptors.
  disk[n].avail[2 + (disk[n].avail[1] % NUM)] = idx[0];
    800062d8:	6698                	ld	a4,8(a3)
    800062da:	00275783          	lhu	a5,2(a4)
    800062de:	8b9d                	andi	a5,a5,7
    800062e0:	2789                	addiw	a5,a5,2
    800062e2:	0786                	slli	a5,a5,0x1
    800062e4:	97ba                	add	a5,a5,a4
    800062e6:	00979023          	sh	s1,0(a5)
  __sync_synchronize();
    800062ea:	0ff0000f          	fence
  disk[n].avail[1] = disk[n].avail[1] + 1;
    800062ee:	6698                	ld	a4,8(a3)
    800062f0:	00275783          	lhu	a5,2(a4)
    800062f4:	2785                	addiw	a5,a5,1
    800062f6:	00f71123          	sh	a5,2(a4)

  *R(n, VIRTIO_MMIO_QUEUE_NOTIFY) = 0; // value is queue number
    800062fa:	0019079b          	addiw	a5,s2,1
    800062fe:	00c7979b          	slliw	a5,a5,0xc
    80006302:	10000737          	lui	a4,0x10000
    80006306:	05070713          	addi	a4,a4,80 # 10000050 <_entry-0x6fffffb0>
    8000630a:	97ba                	add	a5,a5,a4
    8000630c:	0007a023          	sw	zero,0(a5)

  // Wait for virtio_disk_intr() to say request has finished.
  while(b->disk == 1) {
    80006310:	004a2703          	lw	a4,4(s4)
    80006314:	4785                	li	a5,1
    80006316:	00f71d63          	bne	a4,a5,80006330 <virtio_disk_rw+0x274>
    8000631a:	4485                	li	s1,1
    sleep(b, &disk[n].vdisk_lock);
    8000631c:	85ce                	mv	a1,s3
    8000631e:	8552                	mv	a0,s4
    80006320:	ffffc097          	auipc	ra,0xffffc
    80006324:	d8c080e7          	jalr	-628(ra) # 800020ac <sleep>
  while(b->disk == 1) {
    80006328:	004a2783          	lw	a5,4(s4)
    8000632c:	fe9788e3          	beq	a5,s1,8000631c <virtio_disk_rw+0x260>
  }

  disk[n].info[idx[0]].b = 0;
    80006330:	f8042483          	lw	s1,-128(s0)
    80006334:	00191793          	slli	a5,s2,0x1
    80006338:	97ca                	add	a5,a5,s2
    8000633a:	07a2                	slli	a5,a5,0x8
    8000633c:	97a6                	add	a5,a5,s1
    8000633e:	20078793          	addi	a5,a5,512
    80006342:	0792                	slli	a5,a5,0x4
    80006344:	0001d717          	auipc	a4,0x1d
    80006348:	cbc70713          	addi	a4,a4,-836 # 80023000 <disk>
    8000634c:	97ba                	add	a5,a5,a4
    8000634e:	0207b423          	sd	zero,40(a5)
    if(disk[n].desc[i].flags & VRING_DESC_F_NEXT)
    80006352:	00191793          	slli	a5,s2,0x1
    80006356:	97ca                	add	a5,a5,s2
    80006358:	07b2                	slli	a5,a5,0xc
    8000635a:	97ba                	add	a5,a5,a4
    8000635c:	6a09                	lui	s4,0x2
    8000635e:	9a3e                	add	s4,s4,a5
    free_desc(n, i);
    80006360:	85a6                	mv	a1,s1
    80006362:	854a                	mv	a0,s2
    80006364:	00000097          	auipc	ra,0x0
    80006368:	ad4080e7          	jalr	-1324(ra) # 80005e38 <free_desc>
    if(disk[n].desc[i].flags & VRING_DESC_F_NEXT)
    8000636c:	0492                	slli	s1,s1,0x4
    8000636e:	000a3783          	ld	a5,0(s4) # 2000 <_entry-0x7fffe000>
    80006372:	94be                	add	s1,s1,a5
    80006374:	00c4d783          	lhu	a5,12(s1)
    80006378:	8b85                	andi	a5,a5,1
    8000637a:	c78d                	beqz	a5,800063a4 <virtio_disk_rw+0x2e8>
      i = disk[n].desc[i].next;
    8000637c:	00e4d483          	lhu	s1,14(s1)
  while(1){
    80006380:	b7c5                	j	80006360 <virtio_disk_rw+0x2a4>
    disk[n].desc[idx[1]].flags = VRING_DESC_F_WRITE; // device writes b->data
    80006382:	00191793          	slli	a5,s2,0x1
    80006386:	97ca                	add	a5,a5,s2
    80006388:	07b2                	slli	a5,a5,0xc
    8000638a:	0001d717          	auipc	a4,0x1d
    8000638e:	c7670713          	addi	a4,a4,-906 # 80023000 <disk>
    80006392:	973e                	add	a4,a4,a5
    80006394:	6789                	lui	a5,0x2
    80006396:	97ba                	add	a5,a5,a4
    80006398:	639c                	ld	a5,0(a5)
    8000639a:	97b2                	add	a5,a5,a2
    8000639c:	4709                	li	a4,2
    8000639e:	00e79623          	sh	a4,12(a5) # 200c <_entry-0x7fffdff4>
    800063a2:	bd4d                	j	80006254 <virtio_disk_rw+0x198>
  free_chain(n, idx[0]);

  release(&disk[n].vdisk_lock);
    800063a4:	854e                	mv	a0,s3
    800063a6:	ffffa097          	auipc	ra,0xffffa
    800063aa:	7c2080e7          	jalr	1986(ra) # 80000b68 <release>
}
    800063ae:	60aa                	ld	ra,136(sp)
    800063b0:	640a                	ld	s0,128(sp)
    800063b2:	74e6                	ld	s1,120(sp)
    800063b4:	7946                	ld	s2,112(sp)
    800063b6:	79a6                	ld	s3,104(sp)
    800063b8:	7a06                	ld	s4,96(sp)
    800063ba:	6ae6                	ld	s5,88(sp)
    800063bc:	6b46                	ld	s6,80(sp)
    800063be:	6ba6                	ld	s7,72(sp)
    800063c0:	6c06                	ld	s8,64(sp)
    800063c2:	7ce2                	ld	s9,56(sp)
    800063c4:	7d42                	ld	s10,48(sp)
    800063c6:	7da2                	ld	s11,40(sp)
    800063c8:	6149                	addi	sp,sp,144
    800063ca:	8082                	ret
  if(write)
    800063cc:	de0d9de3          	bnez	s11,800061c6 <virtio_disk_rw+0x10a>
    buf0.type = VIRTIO_BLK_T_IN; // read the disk
    800063d0:	f6042823          	sw	zero,-144(s0)
    800063d4:	bbe5                	j	800061cc <virtio_disk_rw+0x110>
      disk[n].free[i] = 0;
    800063d6:	000c0c23          	sb	zero,24(s8)
    idx[i] = alloc_desc(n);
    800063da:	00072023          	sw	zero,0(a4)
    if(idx[i] < 0){
    800063de:	b3ad                	j	80006148 <virtio_disk_rw+0x8c>

00000000800063e0 <virtio_disk_intr>:

void
virtio_disk_intr(int n)
{
    800063e0:	7139                	addi	sp,sp,-64
    800063e2:	fc06                	sd	ra,56(sp)
    800063e4:	f822                	sd	s0,48(sp)
    800063e6:	f426                	sd	s1,40(sp)
    800063e8:	f04a                	sd	s2,32(sp)
    800063ea:	ec4e                	sd	s3,24(sp)
    800063ec:	e852                	sd	s4,16(sp)
    800063ee:	e456                	sd	s5,8(sp)
    800063f0:	0080                	addi	s0,sp,64
    800063f2:	84aa                	mv	s1,a0
  acquire(&disk[n].vdisk_lock);
    800063f4:	00151913          	slli	s2,a0,0x1
    800063f8:	00a90a33          	add	s4,s2,a0
    800063fc:	0a32                	slli	s4,s4,0xc
    800063fe:	6989                	lui	s3,0x2
    80006400:	0b098793          	addi	a5,s3,176 # 20b0 <_entry-0x7fffdf50>
    80006404:	9a3e                	add	s4,s4,a5
    80006406:	0001da97          	auipc	s5,0x1d
    8000640a:	bfaa8a93          	addi	s5,s5,-1030 # 80023000 <disk>
    8000640e:	9a56                	add	s4,s4,s5
    80006410:	8552                	mv	a0,s4
    80006412:	ffffa097          	auipc	ra,0xffffa
    80006416:	6ee080e7          	jalr	1774(ra) # 80000b00 <acquire>

  while((disk[n].used_idx % NUM) != (disk[n].used->id % NUM)){
    8000641a:	9926                	add	s2,s2,s1
    8000641c:	0932                	slli	s2,s2,0xc
    8000641e:	9956                	add	s2,s2,s5
    80006420:	99ca                	add	s3,s3,s2
    80006422:	0209d683          	lhu	a3,32(s3)
    80006426:	0109b703          	ld	a4,16(s3)
    8000642a:	00275783          	lhu	a5,2(a4)
    8000642e:	8fb5                	xor	a5,a5,a3
    80006430:	8b9d                	andi	a5,a5,7
    80006432:	cbd1                	beqz	a5,800064c6 <virtio_disk_intr+0xe6>
    int id = disk[n].used->elems[disk[n].used_idx].id;
    80006434:	068e                	slli	a3,a3,0x3
    80006436:	9736                	add	a4,a4,a3
    80006438:	435c                	lw	a5,4(a4)

    if(disk[n].info[id].status != 0)
    8000643a:	00149713          	slli	a4,s1,0x1
    8000643e:	9726                	add	a4,a4,s1
    80006440:	0722                	slli	a4,a4,0x8
    80006442:	973e                	add	a4,a4,a5
    80006444:	20070713          	addi	a4,a4,512
    80006448:	0712                	slli	a4,a4,0x4
    8000644a:	9756                	add	a4,a4,s5
    8000644c:	03074703          	lbu	a4,48(a4)
    80006450:	e33d                	bnez	a4,800064b6 <virtio_disk_intr+0xd6>
      panic("virtio_disk_intr status");
    
    disk[n].info[id].b->disk = 0;   // disk is done with buf
    80006452:	8956                	mv	s2,s5
    80006454:	00149713          	slli	a4,s1,0x1
    80006458:	9726                	add	a4,a4,s1
    8000645a:	00871993          	slli	s3,a4,0x8
    wakeup(disk[n].info[id].b);

    disk[n].used_idx = (disk[n].used_idx + 1) % NUM;
    8000645e:	0732                	slli	a4,a4,0xc
    80006460:	9756                	add	a4,a4,s5
    80006462:	6489                	lui	s1,0x2
    80006464:	94ba                	add	s1,s1,a4
    disk[n].info[id].b->disk = 0;   // disk is done with buf
    80006466:	97ce                	add	a5,a5,s3
    80006468:	20078793          	addi	a5,a5,512
    8000646c:	0792                	slli	a5,a5,0x4
    8000646e:	97ca                	add	a5,a5,s2
    80006470:	7798                	ld	a4,40(a5)
    80006472:	00072223          	sw	zero,4(a4)
    wakeup(disk[n].info[id].b);
    80006476:	7788                	ld	a0,40(a5)
    80006478:	ffffc097          	auipc	ra,0xffffc
    8000647c:	d80080e7          	jalr	-640(ra) # 800021f8 <wakeup>
    disk[n].used_idx = (disk[n].used_idx + 1) % NUM;
    80006480:	0204d783          	lhu	a5,32(s1) # 2020 <_entry-0x7fffdfe0>
    80006484:	2785                	addiw	a5,a5,1
    80006486:	8b9d                	andi	a5,a5,7
    80006488:	03079613          	slli	a2,a5,0x30
    8000648c:	9241                	srli	a2,a2,0x30
    8000648e:	02c49023          	sh	a2,32(s1)
  while((disk[n].used_idx % NUM) != (disk[n].used->id % NUM)){
    80006492:	6898                	ld	a4,16(s1)
    80006494:	00275683          	lhu	a3,2(a4)
    80006498:	8a9d                	andi	a3,a3,7
    8000649a:	02c68663          	beq	a3,a2,800064c6 <virtio_disk_intr+0xe6>
    int id = disk[n].used->elems[disk[n].used_idx].id;
    8000649e:	078e                	slli	a5,a5,0x3
    800064a0:	97ba                	add	a5,a5,a4
    800064a2:	43dc                	lw	a5,4(a5)
    if(disk[n].info[id].status != 0)
    800064a4:	00f98733          	add	a4,s3,a5
    800064a8:	20070713          	addi	a4,a4,512
    800064ac:	0712                	slli	a4,a4,0x4
    800064ae:	974a                	add	a4,a4,s2
    800064b0:	03074703          	lbu	a4,48(a4)
    800064b4:	db4d                	beqz	a4,80006466 <virtio_disk_intr+0x86>
      panic("virtio_disk_intr status");
    800064b6:	00001517          	auipc	a0,0x1
    800064ba:	40250513          	addi	a0,a0,1026 # 800078b8 <userret+0x828>
    800064be:	ffffa097          	auipc	ra,0xffffa
    800064c2:	0c0080e7          	jalr	192(ra) # 8000057e <panic>
  }

  release(&disk[n].vdisk_lock);
    800064c6:	8552                	mv	a0,s4
    800064c8:	ffffa097          	auipc	ra,0xffffa
    800064cc:	6a0080e7          	jalr	1696(ra) # 80000b68 <release>
}
    800064d0:	70e2                	ld	ra,56(sp)
    800064d2:	7442                	ld	s0,48(sp)
    800064d4:	74a2                	ld	s1,40(sp)
    800064d6:	7902                	ld	s2,32(sp)
    800064d8:	69e2                	ld	s3,24(sp)
    800064da:	6a42                	ld	s4,16(sp)
    800064dc:	6aa2                	ld	s5,8(sp)
    800064de:	6121                	addi	sp,sp,64
    800064e0:	8082                	ret
	...

0000000080007000 <trampoline>:
    80007000:	14051573          	csrrw	a0,sscratch,a0
    80007004:	02153423          	sd	ra,40(a0)
    80007008:	02253823          	sd	sp,48(a0)
    8000700c:	02353c23          	sd	gp,56(a0)
    80007010:	04453023          	sd	tp,64(a0)
    80007014:	04553423          	sd	t0,72(a0)
    80007018:	04653823          	sd	t1,80(a0)
    8000701c:	04753c23          	sd	t2,88(a0)
    80007020:	f120                	sd	s0,96(a0)
    80007022:	f524                	sd	s1,104(a0)
    80007024:	fd2c                	sd	a1,120(a0)
    80007026:	e150                	sd	a2,128(a0)
    80007028:	e554                	sd	a3,136(a0)
    8000702a:	e958                	sd	a4,144(a0)
    8000702c:	ed5c                	sd	a5,152(a0)
    8000702e:	0b053023          	sd	a6,160(a0)
    80007032:	0b153423          	sd	a7,168(a0)
    80007036:	0b253823          	sd	s2,176(a0)
    8000703a:	0b353c23          	sd	s3,184(a0)
    8000703e:	0d453023          	sd	s4,192(a0)
    80007042:	0d553423          	sd	s5,200(a0)
    80007046:	0d653823          	sd	s6,208(a0)
    8000704a:	0d753c23          	sd	s7,216(a0)
    8000704e:	0f853023          	sd	s8,224(a0)
    80007052:	0f953423          	sd	s9,232(a0)
    80007056:	0fa53823          	sd	s10,240(a0)
    8000705a:	0fb53c23          	sd	s11,248(a0)
    8000705e:	11c53023          	sd	t3,256(a0)
    80007062:	11d53423          	sd	t4,264(a0)
    80007066:	11e53823          	sd	t5,272(a0)
    8000706a:	11f53c23          	sd	t6,280(a0)
    8000706e:	140022f3          	csrr	t0,sscratch
    80007072:	06553823          	sd	t0,112(a0)
    80007076:	00853103          	ld	sp,8(a0)
    8000707a:	02053203          	ld	tp,32(a0)
    8000707e:	01053283          	ld	t0,16(a0)
    80007082:	00053303          	ld	t1,0(a0)
    80007086:	18031073          	csrw	satp,t1
    8000708a:	12000073          	sfence.vma
    8000708e:	8282                	jr	t0

0000000080007090 <userret>:
    80007090:	18059073          	csrw	satp,a1
    80007094:	12000073          	sfence.vma
    80007098:	07053283          	ld	t0,112(a0)
    8000709c:	14029073          	csrw	sscratch,t0
    800070a0:	02853083          	ld	ra,40(a0)
    800070a4:	03053103          	ld	sp,48(a0)
    800070a8:	03853183          	ld	gp,56(a0)
    800070ac:	04053203          	ld	tp,64(a0)
    800070b0:	04853283          	ld	t0,72(a0)
    800070b4:	05053303          	ld	t1,80(a0)
    800070b8:	05853383          	ld	t2,88(a0)
    800070bc:	7120                	ld	s0,96(a0)
    800070be:	7524                	ld	s1,104(a0)
    800070c0:	7d2c                	ld	a1,120(a0)
    800070c2:	6150                	ld	a2,128(a0)
    800070c4:	6554                	ld	a3,136(a0)
    800070c6:	6958                	ld	a4,144(a0)
    800070c8:	6d5c                	ld	a5,152(a0)
    800070ca:	0a053803          	ld	a6,160(a0)
    800070ce:	0a853883          	ld	a7,168(a0)
    800070d2:	0b053903          	ld	s2,176(a0)
    800070d6:	0b853983          	ld	s3,184(a0)
    800070da:	0c053a03          	ld	s4,192(a0)
    800070de:	0c853a83          	ld	s5,200(a0)
    800070e2:	0d053b03          	ld	s6,208(a0)
    800070e6:	0d853b83          	ld	s7,216(a0)
    800070ea:	0e053c03          	ld	s8,224(a0)
    800070ee:	0e853c83          	ld	s9,232(a0)
    800070f2:	0f053d03          	ld	s10,240(a0)
    800070f6:	0f853d83          	ld	s11,248(a0)
    800070fa:	10053e03          	ld	t3,256(a0)
    800070fe:	10853e83          	ld	t4,264(a0)
    80007102:	11053f03          	ld	t5,272(a0)
    80007106:	11853f83          	ld	t6,280(a0)
    8000710a:	14051573          	csrrw	a0,sscratch,a0
    8000710e:	10200073          	sret
